From f025c0def98fd72f7e3180a208d896414c451e63 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 1 Oct 2012 16:13:41 +0200 Subject: C linkage cleanup * decleared main() with C linkage since it might be renamed to SDL_main and libSDLmain's startup code expects C linkage * use a custom atexit() handler since SDL_Quit() calling conventions might differ from standard C calling conventions --- src/main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 1f15c6e..f055db5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,13 @@ /* * Declarations */ +extern "C" { + +int main(int argc, char **argv); +static void cleanup(void); + +} + SDL_Surface *screen; OSCServer osc_server; @@ -194,7 +201,7 @@ main(int argc, char **argv) SDL_ERROR("SDL_Init"); return EXIT_FAILURE; } - atexit(SDL_Quit); + atexit(cleanup); SDL_WM_SetCaption("OSC Graphics", NULL); @@ -235,6 +242,12 @@ main(int argc, char **argv) return EXIT_FAILURE; } +static void +cleanup(void) +{ + SDL_Quit(); +} + #if defined(__WIN32__) && defined(main) #undef main /* -- cgit v1.2.3