Odd problem...

Started by
8 comments, last by Oberon_Command 18 years, 7 months ago
I have an odd problem. I'm writing a simple RTS game for 4e4, and every time my game quits, it causes an access violation. I tried commenting out my entire main file, so that I was left with this:

int main (int argc, char *argv[])
{
 return 0;
}
Still, the error occurred. I tried running it through a debugger, and I didn't really get anything (Stupid Dev-C++...). Does anybody know why this might happen?
Advertisement
Even with that tiny stub of a main function, global variables are still constructed and destroyed.
...it could be something weird like not rebooting your machine in a long time.

Just for fun try main() without any parameters, and also try with void as return type; see if these make any difference.
Also, try stepping through the code (I realize it's just one line), and when the crash occurs see the stack-trace. Perhaps you will see more information.
1. I removed all #include<> commands as well, so it can't be from that.
2. I'll try main() without any parameters, but since I'm using C++ I may get an error from declaring it void instead of int. And I reboot my machine every night (it boots up rather quickly, it's a laptop so it has to). Also, the error happens on every computer that I test it on.
3. I know that the error occurs when I return from the function. If I omit that, it may fix it, but then again I'll probably get errors and warnings. I'll try that, though.

So a destructor of a global variable is failing. I hope you didn't think that removing the includes would disable the instantiation of global variables defined in other translation units?
It can't be globals, because I only have 5 globals in my program, and they're all integers. The main objects are all created in main().
Have you tried a full rebuild?
I seriously doubt this will help. But try only having this in your
command line (for testing purposes)
int main(void){   return(0);}

See if it gives you that error then.
Never mind. Solved it on my own. Turns out it was a global deconstructor (there was a global that I thought was a member variable. A plague on my bad eyes!).

This topic is closed to new replies.

Advertisement