Sign in to follow this  
Specchum

SDL problem - exception galore!

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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().

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this