Jump to content
  • Advertisement
Sign in to follow this  
ELFanatic

odd problem

This topic is 4414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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>?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!