Allow you to override SDL's main override
authorSam Lantinga <slouken@libsdl.org>
Wed, 16 Feb 2011 12:27:29 -0800
changeset 5320 e4add1082c2e
parent 5319 675d18cbdbad
child 5321 a6b86cbfc174
Allow you to override SDL's main override
include/SDL_main.h
--- a/include/SDL_main.h	Wed Feb 16 12:15:04 2011 -0800
+++ b/include/SDL_main.h	Wed Feb 16 12:27:29 2011 -0800
@@ -31,10 +31,11 @@
  *  Redefine main() on some platforms so that it is called by SDL.
  */
 
-#if defined(__WIN32__) || \
-    (defined(__MWERKS__) && !defined(__BEOS__)) || \
-    defined(__SYMBIAN32__) || defined(__IPHONEOS__) || \
-    defined(__ANDROID__)
+#if defined(__WIN32__) || defined(__IPHONEOS__) || defined(__ANDROID__)
+#ifndef SDL_MAIN_HANDLED
+#define SDL_MAIN_NEEDED
+#endif
+#endif
 
 #ifdef __cplusplus
 #define C_LINKAGE	"C"
@@ -57,7 +58,9 @@
  *  \endcode
  */
 
+#ifdef SDL_MAIN_NEEDED
 #define main	SDL_main
+#endif
 
 /**
  *  The prototype for the application's main() function
@@ -65,9 +68,6 @@
 extern C_LINKAGE int SDL_main(int argc, char *argv[]);
 
 
-/* From the SDL library code -- needed for registering the app on Win32 */
-#ifdef __WIN32__
-
 #include "begin_code.h"
 #ifdef __cplusplus
 /* *INDENT-OFF* */
@@ -75,6 +75,8 @@
 /* *INDENT-ON* */
 #endif
 
+#ifdef __WIN32__
+
 /**
  *  This can be called to set the application class at startup
  */
@@ -82,15 +84,15 @@
                                             void *hInst);
 extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
 
+#endif /* __WIN32__ */
+
+
 #ifdef __cplusplus
 /* *INDENT-OFF* */
 }
 /* *INDENT-ON* */
 #endif
 #include "close_code.h"
-#endif
-
-#endif /* Need to redefine main()? */
 
 #endif /* _SDL_main_h */