SDL 3.0
SDL_main.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * # CategoryMain
24 *
25 * Redefine main() if necessary so that it is called by SDL.
26 *
27 * In order to make this consistent on all platforms, the application's main()
28 * should look like this:
29 *
30 * ```c
31 * int main(int argc, char *argv[])
32 * {
33 * }
34 * ```
35 *
36 * SDL will take care of platform specific details on how it gets called.
37 *
38 * This is also where an app can be configured to use the main callbacks, via
39 * the SDL_MAIN_USE_CALLBACKS macro.
40 *
41 * This is a "single-header library," which is to say that including this
42 * header inserts code into your program, and you should only include it once
43 * in most cases. SDL.h does not include this header automatically.
44 *
45 * For more information, see:
46 *
47 * https://wiki.libsdl.org/SDL3/README/main-functions
48 */
49
50#ifndef SDL_main_h_
51#define SDL_main_h_
52
54#include <SDL3/SDL_stdinc.h>
55#include <SDL3/SDL_error.h>
56#include <SDL3/SDL_events.h>
57
58#ifdef SDL_WIKI_DOCUMENTATION_SECTION
59
60/**
61 * Inform SDL that the app is providing an entry point instead of SDL.
62 *
63 * SDL does not define this macro, but will check if it is defined when
64 * including `SDL_main.h`. If defined, SDL will expect the app to provide the
65 * proper entry point for the platform, and all the other magic details
66 * needed, like manually calling SDL_SetMainReady.
67 *
68 * Please see [README/main-functions](README/main-functions), (or
69 * docs/README-main-functions.md in the source tree) for a more detailed
70 * explanation.
71 *
72 * \since This macro is used by the headers since SDL 3.1.3.
73 */
74#define SDL_MAIN_HANDLED 1
75
76/**
77 * Inform SDL to use the main callbacks instead of main.
78 *
79 * SDL does not define this macro, but will check if it is defined when
80 * including `SDL_main.h`. If defined, SDL will expect the app to provide
81 * several functions: SDL_AppInit, SDL_AppEvent, SDL_AppIterate, and
82 * SDL_AppQuit. The app should not provide a `main` function in this case, and
83 * doing so will likely cause the build to fail.
84 *
85 * Please see [README/main-functions](README/main-functions), (or
86 * docs/README-main-functions.md in the source tree) for a more detailed
87 * explanation.
88 *
89 * \since This macro is used by the headers since SDL 3.1.3.
90 *
91 * \sa SDL_AppInit
92 * \sa SDL_AppEvent
93 * \sa SDL_AppIterate
94 * \sa SDL_AppQuit
95 */
96#define SDL_MAIN_USE_CALLBACKS 1
97
98/**
99 * Defined if the target platform offers a special mainline through SDL.
100 *
101 * This won't be defined otherwise. If defined, SDL's headers will redefine
102 * `main` to `SDL_main`.
103 *
104 * This macro is defined by `SDL_main.h`, which is not automatically included
105 * by `SDL.h`.
106 *
107 * Even if available, an app can define SDL_MAIN_HANDLED and provide their
108 * own, if they know what they're doing.
109 *
110 * This macro is used internally by SDL, and apps probably shouldn't rely on it.
111 *
112 * \since This macro is available since SDL 3.1.3.
113 */
114#define SDL_MAIN_AVAILABLE
115
116/**
117 * Defined if the target platform _requires_ a special mainline through SDL.
118 *
119 * This won't be defined otherwise. If defined, SDL's headers will redefine
120 * `main` to `SDL_main`.
121 *
122 * This macro is defined by `SDL_main.h`, which is not automatically included
123 * by `SDL.h`.
124 *
125 * Even if required, an app can define SDL_MAIN_HANDLED and provide their
126 * own, if they know what they're doing.
127 *
128 * This macro is used internally by SDL, and apps probably shouldn't rely on it.
129 *
130 * \since This macro is available since SDL 3.1.3.
131 */
132#define SDL_MAIN_NEEDED
133
134#endif
135
136#ifndef SDL_MAIN_HANDLED
137 #if defined(SDL_PLATFORM_PRIVATE_MAIN)
138 /* Private platforms may have their own ideas about entry points. */
139 #include "SDL_main_private.h"
140
141 #elif defined(SDL_PLATFORM_WIN32)
142 /* On Windows SDL provides WinMain(), which parses the command line and passes
143 the arguments to your main function.
144
145 If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
146 */
147 #define SDL_MAIN_AVAILABLE
148
149 #elif defined(SDL_PLATFORM_GDK)
150 /* On GDK, SDL provides a main function that initializes the game runtime.
151
152 If you prefer to write your own WinMain-function instead of having SDL
153 provide one that calls your main() function,
154 #define SDL_MAIN_HANDLED before #include'ing SDL_main.h
155 and call the SDL_RunApp function from your entry point.
156 */
157 #define SDL_MAIN_NEEDED
158
159 #elif defined(SDL_PLATFORM_IOS)
160 /* On iOS SDL provides a main function that creates an application delegate
161 and starts the iOS application run loop.
162
163 To use it, just #include SDL_main.h in the source file that contains your
164 main() function.
165
166 See src/video/uikit/SDL_uikitappdelegate.m for more details.
167 */
168 #define SDL_MAIN_NEEDED
169
170 #elif defined(SDL_PLATFORM_ANDROID)
171 /* On Android SDL provides a Java class in SDLActivity.java that is the
172 main activity entry point.
173
174 See docs/README-android.md for more details on extending that class.
175 */
176 #define SDL_MAIN_NEEDED
177
178 /* As this is launched from Java, the real entry point (main() function)
179 is outside of the the binary built from this code.
180 This define makes sure that, unlike on other platforms, SDL_main.h
181 and SDL_main_impl.h export an `SDL_main()` function (to be called
182 from Java), but don't implement a native `int main(int argc, char* argv[])`
183 or similar.
184 */
185 #define SDL_MAIN_EXPORTED
186
187 #elif defined(SDL_PLATFORM_EMSCRIPTEN)
188 /* On Emscripten, SDL provides a main function that converts URL
189 parameters that start with "SDL_" to environment variables, so
190 they can be used as SDL hints, etc.
191
192 This is 100% optional, so if you don't want this to happen, you may
193 define SDL_MAIN_HANDLED
194 */
195 #define SDL_MAIN_AVAILABLE
196
197 #elif defined(SDL_PLATFORM_PSP)
198 /* On PSP SDL provides a main function that sets the module info,
199 activates the GPU and starts the thread required to be able to exit
200 the software.
201
202 If you provide this yourself, you may define SDL_MAIN_HANDLED
203 */
204 #define SDL_MAIN_AVAILABLE
205
206 #elif defined(SDL_PLATFORM_PS2)
207 #define SDL_MAIN_AVAILABLE
208
209 #define SDL_PS2_SKIP_IOP_RESET() \
210 void reset_IOP(); \
211 void reset_IOP() {}
212
213 #elif defined(SDL_PLATFORM_3DS)
214 /*
215 On N3DS, SDL provides a main function that sets up the screens
216 and storage.
217
218 If you provide this yourself, you may define SDL_MAIN_HANDLED
219 */
220 #define SDL_MAIN_AVAILABLE
221
222 #endif
223#endif /* SDL_MAIN_HANDLED */
224
225
226#ifdef SDL_WIKI_DOCUMENTATION_SECTION
227
228/**
229 * A macro to tag a main entry point function as exported.
230 *
231 * Most platforms don't need this, and the macro will be defined to nothing.
232 * Some, like Android, keep the entry points in a shared library and need to
233 * explicitly export the symbols.
234 *
235 * External code rarely needs this, and if it needs something, it's almost
236 * always SDL_DECLSPEC instead.
237 *
238 * \since This macro is available since SDL 3.1.3.
239 *
240 * \sa SDL_DECLSPEC
241 */
242#define SDLMAIN_DECLSPEC
243
244#elif defined(SDL_MAIN_EXPORTED)
245/* We need to export SDL_main so it can be launched from external code,
246 like SDLActivity.java on Android */
247#define SDLMAIN_DECLSPEC SDL_DECLSPEC
248#else
249/* usually this is empty */
250#define SDLMAIN_DECLSPEC
251#endif /* SDL_MAIN_EXPORTED */
252
253#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) || defined(SDL_MAIN_USE_CALLBACKS)
254#define main SDL_main
255#endif
256
257#include <SDL3/SDL_init.h>
258#include <SDL3/SDL_begin_code.h>
259#ifdef __cplusplus
260extern "C" {
261#endif
262
263/*
264 * You can (optionally!) define SDL_MAIN_USE_CALLBACKS before including
265 * SDL_main.h, and then your application will _not_ have a standard
266 * "main" entry point. Instead, it will operate as a collection of
267 * functions that are called as necessary by the system. On some
268 * platforms, this is just a layer where SDL drives your program
269 * instead of your program driving SDL, on other platforms this might
270 * hook into the OS to manage the lifecycle. Programs on most platforms
271 * can use whichever approach they prefer, but the decision boils down
272 * to:
273 *
274 * - Using a standard "main" function: this works like it always has for
275 * the past 50+ years in C programming, and your app is in control.
276 * - Using the callback functions: this might clean up some code,
277 * avoid some #ifdef blocks in your program for some platforms, be more
278 * resource-friendly to the system, and possibly be the primary way to
279 * access some future platforms (but none require this at the moment).
280 *
281 * This is up to the app; both approaches are considered valid and supported
282 * ways to write SDL apps.
283 *
284 * If using the callbacks, don't define a "main" function. Instead, implement
285 * the functions listed below in your program.
286 */
287#ifdef SDL_MAIN_USE_CALLBACKS
288
289/**
290 * App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps.
291 *
292 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
293 * standard "main" function, you should not supply this.
294 *
295 * This function is called by SDL once, at startup. The function should
296 * initialize whatever is necessary, possibly create windows and open audio
297 * devices, etc. The `argc` and `argv` parameters work like they would with a
298 * standard "main" function.
299 *
300 * This function should not go into an infinite mainloop; it should do any
301 * one-time setup it requires and then return.
302 *
303 * The app may optionally assign a pointer to `*appstate`. This pointer will
304 * be provided on every future call to the other entry points, to allow
305 * application state to be preserved between functions without the app needing
306 * to use a global variable. If this isn't set, the pointer will be NULL in
307 * future entry points.
308 *
309 * If this function returns SDL_APP_CONTINUE, the app will proceed to normal
310 * operation, and will begin receiving repeated calls to SDL_AppIterate and
311 * SDL_AppEvent for the life of the program. If this function returns
312 * SDL_APP_FAILURE, SDL will call SDL_AppQuit and terminate the process with
313 * an exit code that reports an error to the platform. If it returns
314 * SDL_APP_SUCCESS, SDL calls SDL_AppQuit and terminates with an exit code
315 * that reports success to the platform.
316 *
317 * This function is called by SDL on the main thread.
318 *
319 * \param appstate a place where the app can optionally store a pointer for
320 * future use.
321 * \param argc the standard ANSI C main's argc; number of elements in `argv`.
322 * \param argv the standard ANSI C main's argv; array of command line
323 * arguments.
324 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
325 * terminate with success, SDL_APP_CONTINUE to continue.
326 *
327 * \since This function is available since SDL 3.1.3.
328 *
329 * \sa SDL_AppIterate
330 * \sa SDL_AppEvent
331 * \sa SDL_AppQuit
332 */
333extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[]);
334
335/**
336 * App-implemented iteration entry point for SDL_MAIN_USE_CALLBACKS apps.
337 *
338 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
339 * standard "main" function, you should not supply this.
340 *
341 * This function is called repeatedly by SDL after SDL_AppInit returns 0. The
342 * function should operate as a single iteration the program's primary loop;
343 * it should update whatever state it needs and draw a new frame of video,
344 * usually.
345 *
346 * On some platforms, this function will be called at the refresh rate of the
347 * display (which might change during the life of your app!). There are no
348 * promises made about what frequency this function might run at. You should
349 * use SDL's timer functions if you need to see how much time has passed since
350 * the last iteration.
351 *
352 * There is no need to process the SDL event queue during this function; SDL
353 * will send events as they arrive in SDL_AppEvent, and in most cases the
354 * event queue will be empty when this function runs anyhow.
355 *
356 * This function should not go into an infinite mainloop; it should do one
357 * iteration of whatever the program does and return.
358 *
359 * The `appstate` parameter is an optional pointer provided by the app during
360 * SDL_AppInit(). If the app never provided a pointer, this will be NULL.
361 *
362 * If this function returns SDL_APP_CONTINUE, the app will continue normal
363 * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
364 * the life of the program. If this function returns SDL_APP_FAILURE, SDL will
365 * call SDL_AppQuit and terminate the process with an exit code that reports
366 * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
367 * SDL_AppQuit and terminates with an exit code that reports success to the
368 * platform.
369 *
370 * This function is called by SDL on the main thread.
371 *
372 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
373 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
374 * terminate with success, SDL_APP_CONTINUE to continue.
375 *
376 * \threadsafety This function may get called concurrently with SDL_AppEvent()
377 * for events not pushed on the main thread.
378 *
379 * \since This function is available since SDL 3.1.3.
380 *
381 * \sa SDL_AppInit
382 * \sa SDL_AppEvent
383 */
384extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppIterate(void *appstate);
385
386/**
387 * App-implemented event entry point for SDL_MAIN_USE_CALLBACKS apps.
388 *
389 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
390 * standard "main" function, you should not supply this.
391 *
392 * This function is called as needed by SDL after SDL_AppInit returns
393 * SDL_APP_CONTINUE. It is called once for each new event.
394 *
395 * There is (currently) no guarantee about what thread this will be called
396 * from; whatever thread pushes an event onto SDL's queue will trigger this
397 * function. SDL is responsible for pumping the event queue between each call
398 * to SDL_AppIterate, so in normal operation one should only get events in a
399 * serial fashion, but be careful if you have a thread that explicitly calls
400 * SDL_PushEvent. SDL itself will push events to the queue on the main thread.
401 *
402 * Events sent to this function are not owned by the app; if you need to save
403 * the data, you should copy it.
404 *
405 * This function should not go into an infinite mainloop; it should handle the
406 * provided event appropriately and return.
407 *
408 * The `appstate` parameter is an optional pointer provided by the app during
409 * SDL_AppInit(). If the app never provided a pointer, this will be NULL.
410 *
411 * If this function returns SDL_APP_CONTINUE, the app will continue normal
412 * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
413 * the life of the program. If this function returns SDL_APP_FAILURE, SDL will
414 * call SDL_AppQuit and terminate the process with an exit code that reports
415 * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
416 * SDL_AppQuit and terminates with an exit code that reports success to the
417 * platform.
418 *
419 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
420 * \param event the new event for the app to examine.
421 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
422 * terminate with success, SDL_APP_CONTINUE to continue.
423 *
424 * \threadsafety This function may get called concurrently with
425 * SDL_AppIterate() or SDL_AppQuit() for events not pushed from
426 * the main thread.
427 *
428 * \since This function is available since SDL 3.1.3.
429 *
430 * \sa SDL_AppInit
431 * \sa SDL_AppIterate
432 */
433extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, SDL_Event *event);
434
435/**
436 * App-implemented deinit entry point for SDL_MAIN_USE_CALLBACKS apps.
437 *
438 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
439 * standard "main" function, you should not supply this.
440 *
441 * This function is called once by SDL before terminating the program.
442 *
443 * This function will be called no matter what, even if SDL_AppInit requests
444 * termination.
445 *
446 * This function should not go into an infinite mainloop; it should
447 * deinitialize any resources necessary, perform whatever shutdown activities,
448 * and return.
449 *
450 * You do not need to call SDL_Quit() in this function, as SDL will call it
451 * after this function returns and before the process terminates, but it is
452 * safe to do so.
453 *
454 * The `appstate` parameter is an optional pointer provided by the app during
455 * SDL_AppInit(). If the app never provided a pointer, this will be NULL. This
456 * function call is the last time this pointer will be provided, so any
457 * resources to it should be cleaned up here.
458 *
459 * This function is called by SDL on the main thread.
460 *
461 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
462 * \param result the result code that terminated the app (success or failure).
463 *
464 * \threadsafety SDL_AppEvent() may get called concurrently with this function
465 * if other threads that push events are still active.
466 *
467 * \since This function is available since SDL 3.1.3.
468 *
469 * \sa SDL_AppInit
470 */
471extern SDLMAIN_DECLSPEC void SDLCALL SDL_AppQuit(void *appstate, SDL_AppResult result);
472
473#endif /* SDL_MAIN_USE_CALLBACKS */
474
475
476/**
477 * The prototype for the application's main() function
478 *
479 * \param argc an ANSI-C style main function's argc.
480 * \param argv an ANSI-C style main function's argv.
481 * \returns an ANSI-C main return code; generally 0 is considered successful
482 * program completion, and small non-zero values are considered
483 * errors.
484 *
485 * \since This datatype is available since SDL 3.1.3.
486 */
487typedef int (SDLCALL *SDL_main_func)(int argc, char *argv[]);
488
489/**
490 * An app-supplied function for program entry.
491 *
492 * Apps do not directly create this function; they should create a standard
493 * ANSI-C `main` function instead. If SDL needs to insert some startup code
494 * before `main` runs, or the platform doesn't actually _use_ a function
495 * called "main", SDL will do some macro magic to redefine `main` to
496 * `SDL_main` and provide its own `main`.
497 *
498 * Apps should include `SDL_main.h` in the same file as their `main` function,
499 * and they should not use that symbol for anything else in that file, as it
500 * might get redefined.
501 *
502 * This function is only provided by the app if it isn't using
503 * SDL_MAIN_USE_CALLBACKS.
504 *
505 * Program startup is a surprisingly complex topic. Please see
506 * [README/main-functions](README/main-functions), (or
507 * docs/README-main-functions.md in the source tree) for a more detailed
508 * explanation.
509 *
510 * \param argc an ANSI-C style main function's argc.
511 * \param argv an ANSI-C style main function's argv.
512 * \returns an ANSI-C main return code; generally 0 is considered successful
513 * program completion, and small non-zero values are considered
514 * errors.
515 *
516 * \threadsafety This is the program entry point.
517 *
518 * \since This function is available since SDL 3.1.3.
519 */
520extern SDLMAIN_DECLSPEC int SDLCALL SDL_main(int argc, char *argv[]);
521
522/**
523 * Circumvent failure of SDL_Init() when not using SDL_main() as an entry
524 * point.
525 *
526 * This function is defined in SDL_main.h, along with the preprocessor rule to
527 * redefine main() as SDL_main(). Thus to ensure that your main() function
528 * will not be changed it is necessary to define SDL_MAIN_HANDLED before
529 * including SDL.h.
530 *
531 * \since This function is available since SDL 3.1.3.
532 *
533 * \sa SDL_Init
534 */
535extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void);
536
537/**
538 * Initializes and launches an SDL application, by doing platform-specific
539 * initialization before calling your mainFunction and cleanups after it
540 * returns, if that is needed for a specific platform, otherwise it just calls
541 * mainFunction.
542 *
543 * You can use this if you want to use your own main() implementation without
544 * using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do
545 * *not* need SDL_SetMainReady().
546 *
547 * \param argc the argc parameter from the application's main() function, or 0
548 * if the platform's main-equivalent has no argc.
549 * \param argv the argv parameter from the application's main() function, or
550 * NULL if the platform's main-equivalent has no argv.
551 * \param mainFunction your SDL app's C-style main(). NOT the function you're
552 * calling this from! Its name doesn't matter; it doesn't
553 * literally have to be `main`.
554 * \param reserved should be NULL (reserved for future use, will probably be
555 * platform-specific then).
556 * \returns the return value from mainFunction: 0 on success, otherwise
557 * failure; SDL_GetError() might have more information on the
558 * failure.
559 *
560 * \threadsafety Generally this is called once, near startup, from the
561 * process's initial thread.
562 *
563 * \since This function is available since SDL 3.1.3.
564 */
565extern SDL_DECLSPEC int SDLCALL SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserved);
566
567/**
568 * An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS.
569 *
570 * Generally, you should not call this function directly. This only exists to
571 * hand off work into SDL as soon as possible, where it has a lot more control
572 * and functionality available, and make the inline code in SDL_main.h as
573 * small as possible.
574 *
575 * Not all platforms use this, it's actual use is hidden in a magic
576 * header-only library, and you should not call this directly unless you
577 * _really_ know what you're doing.
578 *
579 * \param argc standard Unix main argc.
580 * \param argv standard Unix main argv.
581 * \param appinit the application's SDL_AppInit function.
582 * \param appiter the application's SDL_AppIterate function.
583 * \param appevent the application's SDL_AppEvent function.
584 * \param appquit the application's SDL_AppQuit function.
585 * \returns standard Unix main return value.
586 *
587 * \threadsafety It is not safe to call this anywhere except as the only
588 * function call in SDL_main.
589 *
590 * \since This function is available since SDL 3.1.3.
591 */
592extern SDL_DECLSPEC int SDLCALL SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit);
593
594
595#if defined(SDL_PLATFORM_WINDOWS)
596
597/**
598 * Register a win32 window class for SDL's use.
599 *
600 * This can be called to set the application window class at startup. It is
601 * safe to call this multiple times, as long as every call is eventually
602 * paired with a call to SDL_UnregisterApp, but a second registration attempt
603 * while a previous registration is still active will be ignored, other than
604 * to increment a counter.
605 *
606 * Most applications do not need to, and should not, call this directly; SDL
607 * will call it when initializing the video subsystem.
608 *
609 * \param name the window class name, in UTF-8 encoding. If NULL, SDL
610 * currently uses "SDL_app" but this isn't guaranteed.
611 * \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
612 * currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
613 * what is specified here.
614 * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
615 * will use `GetModuleHandle(NULL)` instead.
616 * \returns true on success or false on failure; call SDL_GetError() for more
617 * information.
618 *
619 * \since This function is available since SDL 3.1.3.
620 */
621extern SDL_DECLSPEC bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
622
623/**
624 * Deregister the win32 window class from an SDL_RegisterApp call.
625 *
626 * This can be called to undo the effects of SDL_RegisterApp.
627 *
628 * Most applications do not need to, and should not, call this directly; SDL
629 * will call it when deinitializing the video subsystem.
630 *
631 * It is safe to call this multiple times, as long as every call is eventually
632 * paired with a prior call to SDL_RegisterApp. The window class will only be
633 * deregistered when the registration counter in SDL_RegisterApp decrements to
634 * zero through calls to this function.
635 *
636 * \since This function is available since SDL 3.1.3.
637 */
638extern SDL_DECLSPEC void SDLCALL SDL_UnregisterApp(void);
639
640#endif /* defined(SDL_PLATFORM_WINDOWS) */
641
642/**
643 * Callback from the application to let the suspend continue.
644 *
645 * This function is only needed for Xbox GDK support; all other platforms will
646 * do nothing and set an "unsupported" error message.
647 *
648 * \since This function is available since SDL 3.1.3.
649 */
650extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
651
652#ifdef __cplusplus
653}
654#endif
655
656#include <SDL3/SDL_close_code.h>
657
658#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
659 /* include header-only SDL_main implementations */
660 #if defined(SDL_MAIN_USE_CALLBACKS) || defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
661 /* platforms which main (-equivalent) can be implemented in plain C */
662 #include <SDL3/SDL_main_impl.h>
663 #endif
664#endif
665
666#endif /* SDL_main_h_ */
SDL_AppResult(* SDL_AppEvent_func)(void *appstate, SDL_Event *event)
Definition SDL_init.h:164
SDL_AppResult(* SDL_AppInit_func)(void **appstate, int argc, char *argv[])
Definition SDL_init.h:133
SDL_AppResult
Definition SDL_init.h:110
void(* SDL_AppQuit_func)(void *appstate, SDL_AppResult result)
Definition SDL_init.h:178
SDL_AppResult(* SDL_AppIterate_func)(void *appstate)
Definition SDL_init.h:148
void SDL_SetMainReady(void)
SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[])
#define SDLMAIN_DECLSPEC
Definition SDL_main.h:250
int(* SDL_main_func)(int argc, char *argv[])
Definition SDL_main.h:487
int SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserved)
void SDL_GDKSuspendComplete(void)
uint32_t Uint32
Definition SDL_stdinc.h:435