PortNintendo 3DS SDL_main to header-only + SDL_N3DSRunApp()

and move the #undef main and #define main SDL_main to the start/end of
SDL_main_impl.h instead of repeating it in every platform implementation

Thanks to SDL_N3DSRunApp we don't need the #include <3ds.h> in
SDL_main_impl.h - that caused conflicts with testthread.c, because both
have (different) ThreadFunc typedefs.
This commit is contained in:
Daniel Gibson 2022-12-12 04:38:06 +01:00 committed by Sam Lantinga
parent 2aee3e654d
commit 1de559248e
7 changed files with 106 additions and 53 deletions

View file

@ -35,6 +35,12 @@
and main() is implemented in plain C */
#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
/* 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) */
#ifdef main
# undef main
#endif /* main */
#if defined(__WIN32__) || defined(__GDK__)
/* these defines/typedefs are needed for the WinMain() definition */
@ -42,10 +48,6 @@
#define WINAPI __stdcall
#endif
#ifdef main
# undef main
#endif /* main */
#include <SDL3/begin_code.h>
#ifdef __cplusplus
@ -102,9 +104,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#include <SDL3/close_code.h>
/* rename users main() function to SDL_main() so it can be called from the wrapper above */
#define main SDL_main
/* end of __WIN32__ and __GDK__ impls */
#elif defined(__WINRT__)
@ -163,10 +162,6 @@ int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
/* end of WinRT impl */
#elif defined(__IOS__) || defined(__TVOS__)
#ifdef main
# undef main
#endif /* main */
#include <SDL3/begin_code.h>
#ifdef __cplusplus
@ -184,15 +179,35 @@ int main(int argc, char *argv[])
#include <SDL3/close_code.h>
/* rename users main() function to SDL_main() so it can be called from the wrapper above */
#define main SDL_main
/* end of __IOS__ and __TVOS__ impls */
#elif defined(__3DS__)
#include <SDL3/begin_code.h>
#ifdef __cplusplus
extern "C" {
#endif
int main(int argc, char *argv[])
{
return SDL_N3DSRunApp(argc, argv, SDL_main);
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <SDL3/close_code.h>
/* end of __3DS__ impl */
/* TODO: remaining platforms */
#endif /* __WIN32__ etc */
/* 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_windows_h_ */