Importance of SDL_Quit()

Hi

Is SDL_Quit() important if called right before the program exits?? if so, why?
Cant we let the OS just clean up and unload the things that we loaded?

You can do that. SDL_Quit() is mostly useful for shutting down SDL
without quitting the application. For example, an application can have
two sound engines, one SDL, the other FMOD, and can switch them at runtime.

It is, however, good style to explicitly free resources at program
termination.On 07/23/2011 09:53 PM, ShiroAisu wrote:

Hi

Is SDL_Quit() important if called right before the program exits?? if
so, why?
Cant we let the OS just clean up and unload the things that we loaded?

Resource cleanup nowadays is all about style (there are a few other
factors, like quitting SDL before the end of the program). You’ll be a lot
less likely to find someone that appreciates your code if you just leave
everything to the OS.

To be safe, and look good: Call SDL_Quit(); :wink:

Cheers,
Jeaye

Is SDL_Quit() important if called right before the program exits?? if
so, why?
Cant we let the OS just clean up and unload the things that we loaded?

On some platforms (X11, fbcon), if you have a fullscreen video mode and
don’t call SDL_Quit(), the video mode will not be returned to normal
upon program exit.

–ryan.

Those are all great answers :slight_smile: tks everyone.

Apparently you can write:

atexit(SDL_Quit);

At the beginning. Not sure what would happen if you called SDL_Quit manually
as well though…

WilliamOn 24 July 2011 04:53, ShiroAisu wrote:

**
Hi

Is SDL_Quit() important if called right before the program exits?? if so,
why?
Cant we let the OS just clean up and unload the things that we loaded?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

At the beginning. Not sure what would happen if you called SDL_Quit
manually as well though…

You can call SDL_Quit() multiple times. It’s safe to do so.

The truly pedantic will point out that, on some platforms, you can’t
call atexit(SDL_Quit()), because SDL entry points aren’t guaranteed to
be cdecl calling conventions, but this works…

 static void sdlquit(void) { SDL_Quit(); }
 // later...
 atexit(sdlquit);

…and modern versions of Mac OS X can do this awesomeness…

 atexit_b( ^{ SDL_Quit(); } );

…because Blocks make everything cooler. :slight_smile:

–ryan.