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