SDL 2.0
SDL_main.h File Reference
#include "SDL_stdinc.h"
#include "begin_code.h"
#include "close_code.h"
+ Include dependency graph for SDL_main.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SDL_MAIN_AVAILABLE
 
#define SDLMAIN_DECLSPEC
 
#define main   SDL_main
 

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_RegisterApp (const char *name, Uint32 style, void *hInst)
 
void SDL_UnregisterApp (void)
 

Detailed Description

Redefine main() on some platforms so that it is called by SDL.

The application's main() function must be called with C linkage, and should be declared like this:

#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[])
{
}
#define main
Definition SDL_main.h:143

Definition in file SDL_main.h.

Macro Definition Documentation

◆ main

#define main   SDL_main

Definition at line 143 of file SDL_main.h.

◆ SDL_MAIN_AVAILABLE

#define SDL_MAIN_AVAILABLE

Definition at line 40 of file SDL_main.h.

◆ SDLMAIN_DECLSPEC

#define SDLMAIN_DECLSPEC

Definition at line 124 of file SDL_main.h.

Typedef Documentation

◆ SDL_main_func

typedef int(* SDL_main_func) (int argc, char *argv[])

The prototype for the application's main() function

Definition at line 154 of file SDL_main.h.

Function Documentation

◆ SDL_main()

SDLMAIN_DECLSPEC int SDL_main ( int  argc,
char *  argv[] 
)

◆ SDL_RegisterApp()

int SDL_RegisterApp ( const char *  name,
Uint32  style,
void *  hInst 
)

Register a win32 window class for SDL's use.

This can be called to set the application window class at startup. It is safe to call this multiple times, as long as every call is eventually paired with a call to SDL_UnregisterApp, but a second registration attempt while a previous registration is still active will be ignored, other than to increment a counter.

Most applications do not need to, and should not, call this directly; SDL will call it when initializing the video subsystem.

Parameters
namethe window class name, in UTF-8 encoding. If NULL, SDL currently uses "SDL_app" but this isn't guaranteed.
stylethe value to use in WNDCLASSEX::style. If name is NULL, SDL currently uses (CS_BYTEALIGNCLIENT | CS_OWNDC) regardless of what is specified here.
hInstthe HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL will use GetModuleHandle(NULL) instead.
Returns
0 on success, -1 on error. SDL_GetError() may have details.
Since
This function is available since SDL 2.0.2.

◆ SDL_SetMainReady()

void SDL_SetMainReady ( void  )

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.

Since
This function is available since SDL 2.0.0.
See also
SDL_Init

◆ SDL_UnregisterApp()

void SDL_UnregisterApp ( void  )

Deregister the win32 window class from an SDL_RegisterApp call.

This can be called to undo the effects of SDL_RegisterApp.

Most applications do not need to, and should not, call this directly; SDL will call it when deinitializing the video subsystem.

It is safe to call this multiple times, as long as every call is eventually paired with a prior call to SDL_RegisterApp. The window class will only be deregistered when the registration counter in SDL_RegisterApp decrements to zero through calls to this function.

Since
This function is available since SDL 2.0.2.