Exiting SDL in Windows
I wrote a program using Xcode on my Mac. I took the code and compiled it in VC++.Net (VC++ 7). The program runs, but when ever the program comes to the exit() function Windows spits out a write access violation... what is the problem?
1. Are you remembering to include <stdlib.h>?
2. Are you remembering to call SDL_Quit?
2. Are you remembering to call SDL_Quit?
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Yes, I am including <stdlib.h>, and I'm closing out all three libraries I'm using with:TTF_Quit, SDL_Quit, and Mix_CloseAudio
Really? Does it actually crash in exit(), or does it crash in a function that is called by exit()? What does your debugger's stack trace tell you?
When I debug, it says it stops at the function which handles my mouse position and input. But, when I do a printf test it has no problem with the function that handles my mouse position and input and errors out when ever i use the exit() function
If the debugger tells you that there's a problem in your input code, there's a problem in your input code. Of course, it's possible that this is a different error which wasn't being caught without the use of the debugger. Point is, fix what it tells you to fix. [wink]
my input code for the mouse is something like this:
void HandleMouse(int x,int y)
{
...If statements for mouse positions...
}
the in main the mouse x and y position is written to int mouseX and int mouseY
HandleMouse(mouseX,mouseY);
the debugger sees this as an error when it runs into the exit() function
my exit code is the same as all the SDL examples and tutorials... and the code runs fine on OS X
any ideas on what to fix for the input code?
void HandleMouse(int x,int y)
{
...If statements for mouse positions...
}
the in main the mouse x and y position is written to int mouseX and int mouseY
HandleMouse(mouseX,mouseY);
the debugger sees this as an error when it runs into the exit() function
my exit code is the same as all the SDL examples and tutorials... and the code runs fine on OS X
any ideas on what to fix for the input code?
WEll, I'm not sure. You're the one with the code. [wink] Find out what line it's crashing on, then figure out why the crash is occurring, then figure out the appropriate way to stop it from occurring. Access violations generally occur from dereferencing uninitialized or invalidated pointers.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement