main: Indented SDL_main headers for readability, removed SDL2 compat macros.

Specifically, SDL_WinRTRunApp, SDL_UIKitRunApp, and SDL_GDKRunApp macros were
removed, as likely unnecessary to SDL3 users. A note was added to the
migration doc about how to roll replacements. These are not going into
SDL_oldnames.h.

Fixes #8245.
main
Ryan C. Gordon 2024-01-25 17:39:38 -05:00
parent 22ea59425d
commit 8814095aa8
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
3 changed files with 236 additions and 250 deletions

View File

@ -861,7 +861,15 @@ SDL3 doesn't have a static libSDLmain to link against anymore.
Instead SDL_main.h is now a header-only library **and not included by SDL.h anymore**. Instead SDL_main.h is now a header-only library **and not included by SDL.h anymore**.
Using it is really simple: Just `#include <SDL3/SDL_main.h>` in the source file with your standard Using it is really simple: Just `#include <SDL3/SDL_main.h>` in the source file with your standard
`int main(int argc, char* argv[])` function. `int main(int argc, char* argv[])` function. See docs/README-main-functions.md for details.
Several platform-specific entry point functions have been removed as unnecessary. If for some reason you explicitly need them, here are easy replacements:
```c
#define SDL_WinRTRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED)
#define SDL_UIKitRunApp(ARGC, ARGV, MAIN_FUNC) SDL_RunApp(ARGC, ARGV, MAIN_FUNC, NULL)
#define SDL_GDKRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED)
```
## SDL_metal.h ## SDL_metal.h

View File

@ -41,94 +41,93 @@
*/ */
#ifndef SDL_MAIN_HANDLED #ifndef SDL_MAIN_HANDLED
#ifdef SDL_PLATFORM_WIN32 #ifdef SDL_PLATFORM_WIN32
/* On Windows SDL provides WinMain(), which parses the command line and passes /* On Windows SDL provides WinMain(), which parses the command line and passes
the arguments to your main function. the arguments to your main function.
If you provide your own WinMain(), you may define SDL_MAIN_HANDLED If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
*/ */
#define SDL_MAIN_AVAILABLE #define SDL_MAIN_AVAILABLE
#elif defined(SDL_PLATFORM_WINRT) #elif defined(SDL_PLATFORM_WINRT)
/* On WinRT, SDL provides a main function that initializes CoreApplication, /* On WinRT, SDL provides a main function that initializes CoreApplication,
creating an instance of IFrameworkView in the process. creating an instance of IFrameworkView in the process.
Ideally, #include'ing SDL_main.h is enough to get a main() function working. Ideally, #include'ing SDL_main.h is enough to get a main() function working.
However, that requires the source file your main() is in to be compiled However, that requires the source file your main() is in to be compiled
as C++ *and* with the /ZW compiler flag. If that's not feasible, add an as C++ *and* with the /ZW compiler flag. If that's not feasible, add an
otherwise empty .cpp file that only contains `#include <SDL3/SDL_main.h>` otherwise empty .cpp file that only contains `#include <SDL3/SDL_main.h>`
and build that with /ZW (still include SDL_main.h in your other file with main()!). and build that with /ZW (still include SDL_main.h in your other file with main()!).
In XAML apps, instead the function SDL_RunApp() must be called with a pointer In XAML apps, instead the function SDL_RunApp() must be called with a pointer
to the Direct3D-hosted XAML control passed in as the "reserved" argument. to the Direct3D-hosted XAML control passed in as the "reserved" argument.
*/ */
#define SDL_MAIN_NEEDED #define SDL_MAIN_NEEDED
#elif defined(SDL_PLATFORM_GDK) #elif defined(SDL_PLATFORM_GDK)
/* On GDK, SDL provides a main function that initializes the game runtime. /* On GDK, SDL provides a main function that initializes the game runtime.
If you prefer to write your own WinMain-function instead of having SDL If you prefer to write your own WinMain-function instead of having SDL
provide one that calls your main() function, provide one that calls your main() function,
#define SDL_MAIN_HANDLED before #include'ing SDL_main.h #define SDL_MAIN_HANDLED before #include'ing SDL_main.h
and call the SDL_RunApp function from your entry point. and call the SDL_RunApp function from your entry point.
*/ */
#define SDL_MAIN_NEEDED #define SDL_MAIN_NEEDED
#elif defined(SDL_PLATFORM_IOS) #elif defined(SDL_PLATFORM_IOS)
/* On iOS SDL provides a main function that creates an application delegate /* On iOS SDL provides a main function that creates an application delegate
and starts the iOS application run loop. and starts the iOS application run loop.
To use it, just #include SDL_main.h in the source file that contains your To use it, just #include SDL_main.h in the source file that contains your
main() function. main() function.
See src/video/uikit/SDL_uikitappdelegate.m for more details. See src/video/uikit/SDL_uikitappdelegate.m for more details.
*/ */
#define SDL_MAIN_NEEDED #define SDL_MAIN_NEEDED
#elif defined(SDL_PLATFORM_ANDROID) #elif defined(SDL_PLATFORM_ANDROID)
/* On Android SDL provides a Java class in SDLActivity.java that is the /* On Android SDL provides a Java class in SDLActivity.java that is the
main activity entry point. main activity entry point.
See docs/README-android.md for more details on extending that class. See docs/README-android.md for more details on extending that class.
*/ */
#define SDL_MAIN_NEEDED #define SDL_MAIN_NEEDED
/* We need to export SDL_main so it can be launched from Java */ /* We need to export SDL_main so it can be launched from Java */
#define SDLMAIN_DECLSPEC DECLSPEC #define SDLMAIN_DECLSPEC DECLSPEC
#elif defined(SDL_PLATFORM_PSP) #elif defined(SDL_PLATFORM_PSP)
/* On PSP SDL provides a main function that sets the module info, /* On PSP SDL provides a main function that sets the module info,
activates the GPU and starts the thread required to be able to exit activates the GPU and starts the thread required to be able to exit
the software. the software.
If you provide this yourself, you may define SDL_MAIN_HANDLED If you provide this yourself, you may define SDL_MAIN_HANDLED
*/ */
#define SDL_MAIN_AVAILABLE #define SDL_MAIN_AVAILABLE
#elif defined(SDL_PLATFORM_PS2) #elif defined(SDL_PLATFORM_PS2)
#define SDL_MAIN_AVAILABLE #define SDL_MAIN_AVAILABLE
#define SDL_PS2_SKIP_IOP_RESET() \ #define SDL_PS2_SKIP_IOP_RESET() \
void reset_IOP(); \ void reset_IOP(); \
void reset_IOP() {} void reset_IOP() {}
#elif defined(SDL_PLATFORM_3DS) #elif defined(SDL_PLATFORM_3DS)
/* /*
On N3DS, SDL provides a main function that sets up the screens On N3DS, SDL provides a main function that sets up the screens
and storage. and storage.
If you provide this yourself, you may define SDL_MAIN_HANDLED If you provide this yourself, you may define SDL_MAIN_HANDLED
*/ */
#define SDL_MAIN_AVAILABLE #define SDL_MAIN_AVAILABLE
#elif defined(SDL_PLATFORM_NGAGE) #elif defined(SDL_PLATFORM_NGAGE)
/*
TODO: not sure if it should be SDL_MAIN_NEEDED, in SDL2 ngage had a
main implementation, but wasn't mentioned in SDL_main.h
*/
#define SDL_MAIN_AVAILABLE
/* #endif
TODO: not sure if it should be SDL_MAIN_NEEDED, in SDL2 ngage had a
main implementation, but wasn't mentioned in SDL_main.h
*/
#define SDL_MAIN_AVAILABLE
#endif
#endif /* SDL_MAIN_HANDLED */ #endif /* SDL_MAIN_HANDLED */
#ifndef SDLMAIN_DECLSPEC #ifndef SDLMAIN_DECLSPEC
@ -151,7 +150,7 @@
*/ */
#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) || defined(SDL_MAIN_USE_CALLBACKS) #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) || defined(SDL_MAIN_USE_CALLBACKS)
#define main SDL_main #define main SDL_main
#endif #endif
#include <SDL3/SDL_begin_code.h> #include <SDL3/SDL_begin_code.h>
@ -470,26 +469,8 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */ #endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */
#ifdef SDL_PLATFORM_WINRT
/* for compatibility with SDL2's function of this name */
#define SDL_WinRTRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED)
#endif /* SDL_PLATFORM_WINRT */
#ifdef SDL_PLATFORM_IOS
/* for compatibility with SDL2's function of this name */
#define SDL_UIKitRunApp(ARGC, ARGV, MAIN_FUNC) SDL_RunApp(ARGC, ARGV, MAIN_FUNC, NULL)
#endif /* SDL_PLATFORM_IOS */
#ifdef SDL_PLATFORM_GDK #ifdef SDL_PLATFORM_GDK
/* for compatibility with SDL2's function of this name */
#define SDL_GDKRunApp(MAIN_FUNC, RESERVED) SDL_RunApp(0, NULL, MAIN_FUNC, RESERVED)
/** /**
* Callback from the application to let the suspend continue. * Callback from the application to let the suspend continue.
* *
@ -506,31 +487,29 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
#include <SDL3/SDL_close_code.h> #include <SDL3/SDL_close_code.h>
#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) #if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
/* include header-only SDL_main implementations */ /* include header-only SDL_main implementations */
#if defined(SDL_MAIN_USE_CALLBACKS) \ #if defined(SDL_MAIN_USE_CALLBACKS) \
|| defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) \ || defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) \
|| defined(SDL_PLATFORM_3DS) || defined(SDL_PLATFORM_NGAGE) || defined(SDL_PLATFORM_PS2) || defined(SDL_PLATFORM_PSP) || defined(SDL_PLATFORM_3DS) || defined(SDL_PLATFORM_NGAGE) || defined(SDL_PLATFORM_PS2) || defined(SDL_PLATFORM_PSP)
/* platforms which main (-equivalent) can be implemented in plain C */ /* platforms which main (-equivalent) can be implemented in plain C */
#include <SDL3/SDL_main_impl.h> #include <SDL3/SDL_main_impl.h>
#elif defined(SDL_PLATFORM_WINRT) /* C++ platforms */ #elif defined(SDL_PLATFORM_WINRT) /* C++ platforms */
#ifdef __cplusplus
#include <SDL3/SDL_main_impl.h>
#else
/* Note: to get rid of the following warning, you can #define SDL_MAIN_NOIMPL before including SDL_main.h
* in your C sourcefile that contains the standard main. Do *not* use SDL_MAIN_HANDLED for that, then SDL_main won't find your main()!
*/
#ifdef _MSC_VER
#pragma message("Note: Your platform needs the SDL_main implementation in a C++ source file. You can keep your main() in plain C (then continue including SDL_main.h there!) and create a fresh .cpp file that only contains #include <SDL3/SDL_main.h>")
#elif defined(__GNUC__) /* gcc, clang, mingw and compatible are matched by this and have #warning */
#warning "Note: Your platform needs the SDL_main implementation in a C++ source file. You can keep your main() in plain C and create a fresh .cpp file that only contains #include <SDL3/SDL_main.h>"
#endif /* __GNUC__ */
#endif /* __cplusplus */
#ifdef __cplusplus #endif /* C++ platforms like SDL_PLATFORM_WINRT etc */
#include <SDL3/SDL_main_impl.h> #endif
#else
/* Note: to get rid of the following warning, you can #define SDL_MAIN_NOIMPL before including SDL_main.h
* in your C sourcefile that contains the standard main. Do *not* use SDL_MAIN_HANDLED for that, then SDL_main won't find your main()!
*/
#ifdef _MSC_VER
#pragma message("Note: Your platform needs the SDL_main implementation in a C++ source file. You can keep your main() in plain C (then continue including SDL_main.h there!) and create a fresh .cpp file that only contains #include <SDL3/SDL_main.h>")
#elif defined(__GNUC__) /* gcc, clang, mingw and compatible are matched by this and have #warning */
#warning "Note: Your platform needs the SDL_main implementation in a C++ source file. You can keep your main() in plain C and create a fresh .cpp file that only contains #include <SDL3/SDL_main.h>"
#endif /* __GNUC__ */
#endif /* __cplusplus */
#endif /* C++ platforms like SDL_PLATFORM_WINRT etc */
#endif /* SDL_MAIN_HANDLED */
#endif /* SDL_main_h_ */ #endif /* SDL_main_h_ */

View File

@ -35,181 +35,180 @@
and main() is implemented in plain C */ and main() is implemented in plain C */
#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL) #if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
/* the implementations below must be able to use the implement real main(), nothing renamed /* the implementations below must be able to use the implement real main(), nothing renamed
(the user's main() will be renamed to SDL_main so it can be called from here) */ (the user's main() will be renamed to SDL_main so it can be called from here) */
#ifdef main #ifdef main
# undef main #undef main
#endif /* main */ #endif
#ifdef SDL_MAIN_USE_CALLBACKS #ifdef SDL_MAIN_USE_CALLBACKS
#if 0 #if 0
/* currently there are no platforms that _need_ a magic entry point here /* currently there are no platforms that _need_ a magic entry point here
for callbacks, but if one shows up, implement it here. */ for callbacks, but if one shows up, implement it here. */
#else /* use a standard SDL_main, which the app SHOULD NOT ALSO SUPPLY. */ #else /* use a standard SDL_main, which the app SHOULD NOT ALSO SUPPLY. */
/* this define makes the normal SDL_main entry point stuff work...we just provide SDL_main() instead of the app. */ /* this define makes the normal SDL_main entry point stuff work...we just provide SDL_main() instead of the app. */
#define SDL_MAIN_CALLBACK_STANDARD 1 #define SDL_MAIN_CALLBACK_STANDARD 1
int SDL_main(int argc, char **argv) int SDL_main(int argc, char **argv)
{ {
return SDL_EnterAppMainCallbacks(argc, argv, SDL_AppInit, SDL_AppIterate, SDL_AppEvent, SDL_AppQuit); return SDL_EnterAppMainCallbacks(argc, argv, SDL_AppInit, SDL_AppIterate, SDL_AppEvent, SDL_AppQuit);
} }
#endif /* platform-specific tests */ #endif /* platform-specific tests */
#endif /* SDL_MAIN_USE_CALLBACKS */ #endif /* SDL_MAIN_USE_CALLBACKS */
/* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point. */ /* set up the usual SDL_main stuff if we're not using callbacks or if we are but need the normal entry point. */
#if !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) #if !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD)
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) #if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
/* these defines/typedefs are needed for the WinMain() definition */ /* these defines/typedefs are needed for the WinMain() definition */
#ifndef WINAPI #ifndef WINAPI
#define WINAPI __stdcall #define WINAPI __stdcall
#endif #endif
typedef struct HINSTANCE__ * HINSTANCE; typedef struct HINSTANCE__ * HINSTANCE;
typedef char* LPSTR; typedef char* LPSTR;
typedef wchar_t* PWSTR; typedef wchar_t* PWSTR;
/* The VC++ compiler needs main/wmain defined, but not for GDK */ /* The VC++ compiler needs main/wmain defined, but not for GDK */
#if defined(_MSC_VER) && !defined(SDL_PLATFORM_GDK) #if defined(_MSC_VER) && !defined(SDL_PLATFORM_GDK)
/* This is where execution begins [console apps] */ /* This is where execution begins [console apps] */
#if defined( UNICODE ) && UNICODE #if defined( UNICODE ) && UNICODE
int wmain(int argc, wchar_t *wargv[], wchar_t *wenvp) int wmain(int argc, wchar_t *wargv[], wchar_t *wenvp)
{ {
(void)argc; (void)argc;
(void)wargv; (void)wargv;
(void)wenvp; (void)wenvp;
return SDL_RunApp(0, NULL, SDL_main, NULL); return SDL_RunApp(0, NULL, SDL_main, NULL);
} }
#else /* ANSI */ #else /* ANSI */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
(void)argc; (void)argc;
(void)argv; (void)argv;
return SDL_RunApp(0, NULL, SDL_main, NULL); return SDL_RunApp(0, NULL, SDL_main, NULL);
} }
#endif /* UNICODE */ #endif /* UNICODE */
#endif /* _MSC_VER && ! SDL_PLATFORM_GDK */ #endif /* _MSC_VER && ! SDL_PLATFORM_GDK */
/* This is where execution begins [windowed apps and GDK] */ /* This is where execution begins [windowed apps and GDK] */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if defined( UNICODE ) && UNICODE
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw)
#else /* ANSI */
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#endif
{
(void)hInst;
(void)hPrev;
(void)szCmdLine;
(void)sw;
return SDL_RunApp(0, NULL, SDL_main, NULL);
}
#ifdef __cplusplus
} /* extern "C" */
#endif
/* end of SDL_PLATFORM_WIN32 and SDL_PLATFORM_GDK impls */ #if defined( UNICODE ) && UNICODE
#elif defined(SDL_PLATFORM_WINRT) int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw)
#else /* ANSI */
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#endif
{
(void)hInst;
(void)hPrev;
(void)szCmdLine;
(void)sw;
return SDL_RunApp(0, NULL, SDL_main, NULL);
}
/* WinRT main based on SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 */ #ifdef __cplusplus
} /* extern "C" */
#endif
#include <wrl.h> /* end of SDL_PLATFORM_WIN32 and SDL_PLATFORM_GDK impls */
/* At least one file in any SDL/WinRT app appears to require compilation #elif defined(SDL_PLATFORM_WINRT)
with C++/CX, otherwise a Windows Metadata file won't get created, and
an APPX0702 build error can appear shortly after linking.
The following set of preprocessor code forces this file to be compiled /* WinRT main based on SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 */
as C++/CX, which appears to cause Visual C++ 2012's build tools to
create this .winmd file, and will help allow builds of SDL/WinRT apps
to proceed without error.
If other files in an app's project enable C++/CX compilation, then it might #include <wrl.h>
be possible for the .cpp file including SDL_main.h to be compiled without /ZW,
for Visual C++'s build tools to create a winmd file, and for the app to
build without APPX0702 errors. In this case, if
SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then
the #error (to force C++/CX compilation) will be disabled.
Please note that /ZW can be specified on a file-by-file basis. To do this, /* At least one file in any SDL/WinRT app appears to require compilation
right click on the file in Visual C++, click Properties, then change the with C++/CX, otherwise a Windows Metadata file won't get created, and
setting through the dialog that comes up. an APPX0702 build error can appear shortly after linking.
*/
#ifndef SDL_WINRT_METADATA_FILE_AVAILABLE
#if !defined(__cplusplus) || !defined(__cplusplus_winrt)
#error The C++ file that includes SDL_main.h must be compiled as C++ code with /ZW, otherwise build errors due to missing .winmd files can occur.
#endif
#endif
/* Prevent MSVC++ from warning about threading models when defining our The following set of preprocessor code forces this file to be compiled
custom WinMain. The threading model will instead be set via a direct as C++/CX, which appears to cause Visual C++ 2012's build tools to
call to Windows::Foundation::Initialize (rather than via an attributed create this .winmd file, and will help allow builds of SDL/WinRT apps
function). to proceed without error.
To note, this warning (C4447) does not seem to come up unless this file If other files in an app's project enable C++/CX compilation, then it might
is compiled with C++/CX enabled (via the /ZW compiler flag). be possible for the .cpp file including SDL_main.h to be compiled without /ZW,
*/ for Visual C++'s build tools to create a winmd file, and for the app to
#ifdef _MSC_VER build without APPX0702 errors. In this case, if
#pragma warning(disable : 4447) SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then
#endif the #error (to force C++/CX compilation) will be disabled.
/* Make sure the function to initialize the Windows Runtime gets linked in. */ Please note that /ZW can be specified on a file-by-file basis. To do this,
#ifdef _MSC_VER right click on the file in Visual C++, click Properties, then change the
#pragma comment(lib, "runtimeobject.lib") setting through the dialog that comes up.
#endif */
#ifndef SDL_WINRT_METADATA_FILE_AVAILABLE
#if !defined(__cplusplus) || !defined(__cplusplus_winrt)
#error The C++ file that includes SDL_main.h must be compiled as C++ code with /ZW, otherwise build errors due to missing .winmd files can occur.
#endif
#endif
#ifdef __cplusplus /* Prevent MSVC++ from warning about threading models when defining our
extern "C" { custom WinMain. The threading model will instead be set via a direct
#endif call to Windows::Foundation::Initialize (rather than via an attributed
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) function).
{
return SDL_RunApp(0, NULL, SDL_main, NULL);
}
#ifdef __cplusplus
} /* extern "C" */
#endif
/* end of WinRT impl */ To note, this warning (C4447) does not seem to come up unless this file
#elif defined(SDL_PLATFORM_NGAGE) is compiled with C++/CX enabled (via the /ZW compiler flag).
*/
#ifdef _MSC_VER
#pragma warning(disable : 4447)
/* Make sure the function to initialize the Windows Runtime gets linked in. */
#pragma comment(lib, "runtimeobject.lib")
#endif
/* same typedef as in ngage SDKs e32def.h */ #ifdef __cplusplus
typedef signed int TInt; extern "C" {
/* TODO: if it turns out that this only works when built as C++, #endif
move SDL_PLATFORM_NGAGE into the C++ section in SDL_main.h */ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
TInt E32Main() {
{ return SDL_RunApp(0, NULL, SDL_main, NULL);
return SDL_RunApp(0, NULL, SDL_main, NULL); }
} #ifdef __cplusplus
} /* extern "C" */
#endif
/* end of SDL_PLATFORM_NGAGE impl */ /* end of WinRT impl */
#else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */ #elif defined(SDL_PLATFORM_NGAGE)
/* same typedef as in ngage SDKs e32def.h */
typedef signed int TInt;
/* TODO: if it turns out that this only works when built as C++,
move SDL_PLATFORM_NGAGE into the C++ section in SDL_main.h */
TInt E32Main()
{
return SDL_RunApp(0, NULL, SDL_main, NULL);
}
int main(int argc, char *argv[]) /* end of SDL_PLATFORM_NGAGE impl */
{
return SDL_RunApp(argc, argv, SDL_main, NULL);
}
/* end of impls for standard-conforming platforms */ #else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */
int main(int argc, char *argv[])
{
return SDL_RunApp(argc, argv, SDL_main, NULL);
}
#endif /* SDL_PLATFORM_WIN32 etc */ /* end of impls for standard-conforming platforms */
#endif /* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */ #endif /* SDL_PLATFORM_WIN32 etc */
/* rename users main() function to SDL_main() so it can be called from the wrappers above */ #endif /* !defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_CALLBACK_STANDARD) */
#define main SDL_main
/* rename users main() function to SDL_main() so it can be called from the wrappers above */
#define main SDL_main
#endif /* SDL_MAIN_HANDLED */ #endif /* SDL_MAIN_HANDLED */