# Odd problem...

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

## Recommended Posts

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?

##### Share on other sites
Even with that tiny stub of a main function, global variables are still constructed and destroyed.

##### Share on other sites
...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.

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites
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?

##### Share on other sites
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().

##### Share on other sites
Have you tried a full rebuild?

##### Share on other sites
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.

##### Share on other sites
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!).

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633417
• Total Posts
3011781
• ### Who's Online (See full list)

There are no registered users currently online

×