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
parent
22ea59425d
commit
8814095aa8
|
@ -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**.
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -121,7 +121,6 @@
|
|||
#define SDL_MAIN_AVAILABLE
|
||||
|
||||
#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
|
||||
|
@ -470,26 +469,8 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
|
|||
|
||||
#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
|
||||
|
||||
/* 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.
|
||||
*
|
||||
|
@ -515,7 +496,6 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
|
|||
#include <SDL3/SDL_main_impl.h>
|
||||
|
||||
#elif defined(SDL_PLATFORM_WINRT) /* C++ platforms */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <SDL3/SDL_main_impl.h>
|
||||
#else
|
||||
|
@ -530,7 +510,6 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
|
|||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* C++ platforms like SDL_PLATFORM_WINRT etc */
|
||||
|
||||
#endif /* SDL_MAIN_HANDLED */
|
||||
#endif
|
||||
|
||||
#endif /* SDL_main_h_ */
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
(the user's main() will be renamed to SDL_main so it can be called from here) */
|
||||
#ifdef main
|
||||
#undef main
|
||||
#endif /* main */
|
||||
#endif
|
||||
|
||||
#ifdef SDL_MAIN_USE_CALLBACKS
|
||||
|
||||
|
@ -104,6 +104,7 @@ int main(int argc, char *argv[])
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined( UNICODE ) && UNICODE
|
||||
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw)
|
||||
#else /* ANSI */
|
||||
|
@ -116,11 +117,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
|||
(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 */
|
||||
|
||||
#elif defined(SDL_PLATFORM_WINRT)
|
||||
|
||||
/* WinRT main based on SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 */
|
||||
|
@ -163,10 +166,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
|
|||
*/
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4447)
|
||||
#endif
|
||||
|
||||
/* Make sure the function to initialize the Windows Runtime gets linked in. */
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "runtimeobject.lib")
|
||||
#endif
|
||||
|
||||
|
@ -182,8 +182,8 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
|||
#endif
|
||||
|
||||
/* end of WinRT impl */
|
||||
#elif defined(SDL_PLATFORM_NGAGE)
|
||||
|
||||
#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++,
|
||||
|
@ -196,7 +196,6 @@ TInt E32Main()
|
|||
/* end of SDL_PLATFORM_NGAGE impl */
|
||||
|
||||
#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);
|
||||
|
|
Loading…
Reference in New Issue