SDL problem - exception galore!

Started by
3 comments, last by Specchum 18 years, 9 months ago
I'm having a real weird problem that I've not been able to solve despite three days of poring over the code. Hope someone can help! The issue is this: After having used VC6 for sometime I decided to try out VS 2003. No issues with porting over my current VC6 projects. Compiling and linking is fine. However, I notice that all my SDL apps now exit with an exception fault (multiple exceptions via kernel32.dll apparently). Even a simple SDL app that initialises SDL and then quits (and does nothing else) causes these exceptions. The strange thing is that there are no pointers, I'm calling SDL_Quit() and the application is exiting with code 0. So why on earth am I getting exceptions AFTER the app quits? My first thoughts are that it's some dynamic linking that's causing them. But since Vs2003 has only Multithreaded DLL linking, I'm at a loss to get around this. Any help anyone?
"There is no dark side of the moon." - Pink Floyd
Advertisement
Do you by any chance have any global objects that call any SDL functions in their destructors?
Global objects will be destructed after your main exits, and if they call any SDL functions, bad things will happen since you've already called SDL_Quit().

To make it is hell. To fail is divine.

No, the simple SDL app I mentioned is actually the 4-5 line initialisation code given in the SDL docs. Everything is in the main (no globals) and I'm not creating any pointers. Not sure why SDL can't make a graceful exit without tripping up some dll.
"There is no dark side of the moon." - Pink Floyd
A suggestion from the mailing list:
Remove the SDLMain.lib linking, and include SDLMain.c directly in your project*.
Then add these lines to a source file:
#pragma comment(linker,"/ENTRY:mainCRTStartup")
#pragma comment(linker,"/SUBSYSTEM:WINDOWS")

*The sdlmain.c is under a different licence than the rest of SDL, so you can legally do this even if your project isn't LGPL'd.
Ok Travis, I'll try your suggestion when I get back home later in the day! Christ! I hope this works or I swear I'll end up taking the hammer to the comp! :D
"There is no dark side of the moon." - Pink Floyd

This topic is closed to new replies.

Advertisement