SDL 3.0
|
#include <SDL3/SDL_platform_defines.h>
#include <SDL3/SDL_stdinc.h>
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_init.h>
#include <SDL3/SDL_begin_code.h>
#include <SDL3/SDL_close_code.h>
Go to the source code of this file.
Macros | |
#define | SDLMAIN_DECLSPEC |
Typedefs | |
typedef int(* | SDL_main_func) (int argc, char *argv[]) |
Functions | |
SDLMAIN_DECLSPEC int | SDL_main (int argc, char *argv[]) |
void | SDL_SetMainReady (void) |
int | SDL_RunApp (int argc, char *argv[], SDL_main_func mainFunction, void *reserved) |
int | SDL_EnterAppMainCallbacks (int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit) |
The application's main() function must be called with C linkage, and should be declared like this:
Definition in file SDL_main.h.
#define SDLMAIN_DECLSPEC |
Redefine main() on some platforms so that it is called by SDL.
For details on how SDL_main works, and how to use it, please refer to:
https://wiki.libsdl.org/SDL3/README/main-functions
(or docs/README-main-functions.md in the SDL source tree)
Definition at line 129 of file SDL_main.h.
typedef int(* SDL_main_func) (int argc, char *argv[]) |
The prototype for the application's main() function
argc | an ANSI-C style main function's argc. |
argv | an ANSI-C style main function's argv. |
Definition at line 399 of file SDL_main.h.
|
extern |
An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS.
Generally, you should not call this function directly. This only exists to hand off work into SDL as soon as possible, where it has a lot more control and functionality available, and make the inline code in SDL_main.h as small as possible.
Not all platforms use this, it's actual use is hidden in a magic header-only library, and you should not call this directly unless you really know what you're doing.
argc | standard Unix main argc. |
argv | standard Unix main argv. |
appinit | the application's SDL_AppInit function. |
appiter | the application's SDL_AppIterate function. |
appevent | the application's SDL_AppEvent function. |
appquit | the application's SDL_AppQuit function. |
\threadsafety It is not safe to call this anywhere except as the only function call in SDL_main.
|
extern |
An app-supplied function for program entry.
Apps do not directly create this function; they should create a standard ANSI-C main
function instead. If SDL needs to insert some startup code before main
runs, or the platform doesn't actually use a function called "main", SDL will do some macro magic to redefine main
to SDL_main
and provide its own main
.
Apps should include SDL_main.h
in the same file as their main
function, and they should not use that symbol for anything else in that file, as it might get redefined.
This function is only provided by the app if it isn't using SDL_MAIN_USE_CALLBACKS.
Program startup is a surprisingly complex topic. Please see README/main-functions, (or docs/README-main-functions.md in the source tree) for a more detailed explanation.
argc | an ANSI-C style main function's argc. |
argv | an ANSI-C style main function's argv. |
\threadsafety This is the program entry point.
Referenced by main().
|
extern |
Initializes and launches an SDL application, by doing platform-specific initialization before calling your mainFunction and cleanups after it returns, if that is needed for a specific platform, otherwise it just calls mainFunction.
You can use this if you want to use your own main() implementation without using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do not need SDL_SetMainReady().
argc | the argc parameter from the application's main() function, or 0 if the platform's main-equivalent has no argc. |
argv | the argv parameter from the application's main() function, or NULL if the platform's main-equivalent has no argv. |
mainFunction | your SDL app's C-style main(). NOT the function you're calling this from! Its name doesn't matter; it doesn't literally have to be main . |
reserved | should be NULL (reserved for future use, will probably be platform-specific then). |
\threadsafety Generally this is called once, near startup, from the process's initial thread.
Referenced by main().
|
extern |
Circumvent failure of SDL_Init() when not using SDL_main() as an entry point.
This function is defined in SDL_main.h, along with the preprocessor rule to redefine main() as SDL_main(). Thus to ensure that your main() function will not be changed it is necessary to define SDL_MAIN_HANDLED before including SDL.h.