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.
This commit is contained in:
Ryan C. Gordon
2024-01-25 17:39:38 -05:00
parent 22ea59425d
commit 8814095aa8
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

@@ -121,7 +121,6 @@
#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 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 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) */ #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.
* *
@@ -515,7 +496,6 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
#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 #ifdef __cplusplus
#include <SDL3/SDL_main_impl.h> #include <SDL3/SDL_main_impl.h>
#else #else
@@ -530,7 +510,6 @@ extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* C++ platforms like SDL_PLATFORM_WINRT etc */ #endif /* C++ platforms like SDL_PLATFORM_WINRT etc */
#endif
#endif /* SDL_MAIN_HANDLED */
#endif /* SDL_main_h_ */ #endif /* SDL_main_h_ */

View File

@@ -39,7 +39,7 @@
(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
@@ -104,6 +104,7 @@ int main(int argc, char *argv[])
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if defined( UNICODE ) && UNICODE #if defined( UNICODE ) && UNICODE
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw) int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrev, PWSTR szCmdLine, int sw)
#else /* ANSI */ #else /* ANSI */
@@ -116,11 +117,13 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
(void)sw; (void)sw;
return SDL_RunApp(0, NULL, SDL_main, NULL); return SDL_RunApp(0, NULL, SDL_main, NULL);
} }
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
#endif #endif
/* end of SDL_PLATFORM_WIN32 and SDL_PLATFORM_GDK impls */ /* end of SDL_PLATFORM_WIN32 and SDL_PLATFORM_GDK impls */
#elif defined(SDL_PLATFORM_WINRT) #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 */ /* 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 #ifdef _MSC_VER
#pragma warning(disable : 4447) #pragma warning(disable : 4447)
#endif
/* Make sure the function to initialize the Windows Runtime gets linked in. */ /* Make sure the function to initialize the Windows Runtime gets linked in. */
#ifdef _MSC_VER
#pragma comment(lib, "runtimeobject.lib") #pragma comment(lib, "runtimeobject.lib")
#endif #endif
@@ -182,8 +182,8 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
#endif #endif
/* end of WinRT impl */ /* end of WinRT impl */
#elif defined(SDL_PLATFORM_NGAGE)
#elif defined(SDL_PLATFORM_NGAGE)
/* same typedef as in ngage SDKs e32def.h */ /* same typedef as in ngage SDKs e32def.h */
typedef signed int TInt; typedef signed int TInt;
/* TODO: if it turns out that this only works when built as C++, /* 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 */ /* end of SDL_PLATFORM_NGAGE impl */
#else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */ #else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
return SDL_RunApp(argc, argv, SDL_main, NULL); return SDL_RunApp(argc, argv, SDL_main, NULL);