odd problem

Started by
6 comments, last by rip-off 17 years, 5 months ago
oops, I originally posted this in the wrong forum. Anyways, I'm having an odd problem. Probably just an oversight but I'm not seeing it. Here's the problem. void command(inputtedWords *); //Declaration in Adventure //Definition void Adventure::command(inputtedWords * sentence) { if(sentence->next->word == "go") { text = "Holy Cow"; textToType = true; } } I call command with: command(head); Some reason the debugger is telling me that sentence is out of scope and it skips the if statement. I get no complaints from the compiler but the watch says it's out of scope as soon as it enters the function. I've changed sentence into other data types, same problem. I can't for the life of me figure out how it could be out of scope.
Advertisement
Can we see the calling code, and possibly the declaration of "inputtedWords".

Is inputtedWords an implementation of a linked list?

If so, why is it not of type std::list<std::string>?
Are you sure you're running the debugger on a Debug build and not a Release build? I dunno offhand if that would cause that specific problem, but things do seem to get "skipped" a lot if you run the debugger on an executable without debug information.

Just as an aside, where are you putting your breakpoints within the function?
Quote:Original post by rip-off
Can we see the calling code, and possibly the declaration of "inputtedWords".

Is inputtedWords an implementation of a linked list?

If so, why is it not of type std::list<std::string>?


I never knew about this. I will have to look into it. thanks for the tidbit. But I can make sentence an integer and I still have the problem.

The calling code is just
command(head);
In another function of Adventure.
Quote:Original post by MrAccident
Are you sure you're running the debugger on a Debug build and not a Release build? I dunno offhand if that would cause that specific problem, but things do seem to get "skipped" a lot if you run the debugger on an executable without debug information.

Just as an aside, where are you putting your breakpoints within the function?


I went into configuration manager, not sure if this is what I'm supposed to do but I think so, and the active solution configuration is set on Debug and the Project Context is set to debug.
Quote:Original post by ELFanatic
Quote:Original post by rip-off
Can we see the calling code, and possibly the declaration of "inputtedWords".

Is inputtedWords an implementation of a linked list?

If so, why is it not of type std::list<std::string>?


I never knew about this. I will have to look into it. thanks for the tidbit. But I can make sentence an integer and I still have the problem.

The calling code is just
command(head);
In another function of Adventure.


The snippets of code you give us are too small.

We would need something in the region of the function to the file that makes use of command, the file that declares inputtedWords.

If you put plenty of code into source blocks (use the tags [ source ] and [ /source ] without spaces ) we will be better able to tell whats going wrong. The problem is probably outside the scope of Adventure::command, and the single line "commmand(head)" isn't enough. We need to know how head is declared and what is done to it, etc.
it seems I solved it. I had to declare it as void command(inputtedWords * sentence); I always understood that to be optional. But that fixes it so I'll do it.
Quote:Original post by ELFanatic
it seems I solved it. I had to declare it as void command(inputtedWords * sentence); I always understood that to be optional. But that fixes it so I'll do it.


It is optional, but maybe the recompile fixed some other problem.

That can happen occasionally.

This topic is closed to new replies.

Advertisement