Help! Variable initializing won't stick!

Started by
10 comments, last by vinb 19 years, 6 months ago
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?
Advertisement
What debugger are you using?
---PS3dev
Sorry. I'm using Visual Studio.net.
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.
---PS3dev
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>.
Pointer-to-Pointer and Reference-to-Pointer
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?
Try deleting all your object files and recompiling. Sometimes the debug line info goes wrong.
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
No luck.
If it helps, I am creating thisGame right at the beginning of main(). I have the gamestate structure defined in the header.

This topic is closed to new replies.

Advertisement