Jump to content
  • Advertisement
Sign in to follow this  
vinb

Help! Variable initializing won't stick!

This topic is 5121 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

For some reason, I can't seem to assign an values to a variable. In the debugger, it shows 'no runtime value'. Here's what I'm doing:
...
gamestate *thisGame = new gamestate ;
initGame(thisGame) ;

...

void initGame(gamestate *thisGame){

	thisGame->rowcount = 0 ;
	thisGame->score = 0 ;
	thisGame->gameCount = 0 ;
}

It executes each line of code, but seems to just throw away the values. After each line in initGame(), the value in the debugger still shows 'no runtime value'. What's the problem?

Share this post


Link to post
Share on other sites
Advertisement
Hmm. If you're just hovering the mouse over the variables, it won't necessarily 'understand' it. To make sure if it's working, right click on the object (thisGame) and go to quickwatch - does it still say they're uninitialised?

Where in the program's flow are you checking the variable? The variable gameState will have a local scope of the function it's declared in - i.e. it won't be valid once that function returns.

Share this post


Link to post
Share on other sites
I tried the quick watch and for each element of the structure it shows <no runtime value>. I'm checking it immediately after it executes the line of code that sets the variable. It will execute thisGame->rowcount = 0 and still show <no runtime value>.

Share this post


Link to post
Share on other sites
This is even more strange. This produces the same result:


gamestate *thisGame = new gamestate ;
thisGame->rowcount = 0 // still shows <no runtime value>



Am I missing a step to using a pointer to this object?

Share this post


Link to post
Share on other sites
If it helps, I am creating thisGame right at the beginning of main(). I have the gamestate structure defined in the header.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!