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_init.h>
192#include <SDL3/SDL_begin_code.h>
193#ifdef __cplusplus
194extern "C" {
195#endif
196
197/*
198 * You can (optionally!) define SDL_MAIN_USE_CALLBACKS before including
199 * SDL_main.h, and then your application will _not_ have a standard
200 * "main" entry point. Instead, it will operate as a collection of
201 * functions that are called as necessary by the system. On some
202 * platforms, this is just a layer where SDL drives your program
203 * instead of your program driving SDL, on other platforms this might
204 * hook into the OS to manage the lifecycle. Programs on most platforms
205 * can use whichever approach they prefer, but the decision boils down
206 * to:
207 *
208 * - Using a standard "main" function: this works like it always has for
209 * the past 50+ years in C programming, and your app is in control.
210 * - Using the callback functions: this might clean up some code,
211 * avoid some #ifdef blocks in your program for some platforms, be more
212 * resource-friendly to the system, and possibly be the primary way to
213 * access some future platforms (but none require this at the moment).
214 *
215 * This is up to the app; both approaches are considered valid and supported
216 * ways to write SDL apps.
217 *
218 * If using the callbacks, don't define a "main" function. Instead, implement
219 * the functions listed below in your program.
220 */
221#ifdef SDL_MAIN_USE_CALLBACKS
222
223/**
224 * App-implemented initial entry point for SDL_MAIN_USE_CALLBACKS apps.
225 *
226 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
227 * standard "main" function, you should not supply this.
228 *
229 * This function is called by SDL once, at startup. The function should
230 * initialize whatever is necessary, possibly create windows and open audio
231 * devices, etc. The `argc` and `argv` parameters work like they would with a
232 * standard "main" function.
233 *
234 * This function should not go into an infinite mainloop; it should do any
235 * one-time setup it requires and then return.
236 *
237 * The app may optionally assign a pointer to `*appstate`. This pointer will
238 * be provided on every future call to the other entry points, to allow
239 * application state to be preserved between functions without the app needing
240 * to use a global variable. If this isn't set, the pointer will be NULL in
241 * future entry points.
242 *
243 * If this function returns SDL_APP_CONTINUE, the app will proceed to normal
244 * operation, and will begin receiving repeated calls to SDL_AppIterate and
245 * SDL_AppEvent for the life of the program. If this function returns
246 * SDL_APP_FAILURE, SDL will call SDL_AppQuit and terminate the process with
247 * an exit code that reports an error to the platform. If it returns
248 * SDL_APP_SUCCESS, SDL calls SDL_AppQuit and terminates with an exit code
249 * that reports success to the platform.
250 *
251 * \param appstate a place where the app can optionally store a pointer for
252 * future use.
253 * \param argc the standard ANSI C main's argc; number of elements in `argv`.
254 * \param argv the standard ANSI C main's argv; array of command line
255 * arguments.
256 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
257 * terminate with success, SDL_APP_CONTINUE to continue.
258 *
259 * \threadsafety This function is not thread safe.
260 *
261 * \since This function is available since SDL 3.0.0.
262 *
263 * \sa SDL_AppIterate
264 * \sa SDL_AppEvent
265 * \sa SDL_AppQuit
266 */
267extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppInit(void **appstate, int argc, char *argv[]);
268
269/**
270 * App-implemented iteration entry point for SDL_MAIN_USE_CALLBACKS apps.
271 *
272 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
273 * standard "main" function, you should not supply this.
274 *
275 * This function is called repeatedly by SDL after SDL_AppInit returns 0. The
276 * function should operate as a single iteration the program's primary loop;
277 * it should update whatever state it needs and draw a new frame of video,
278 * usually.
279 *
280 * On some platforms, this function will be called at the refresh rate of the
281 * display (which might change during the life of your app!). There are no
282 * promises made about what frequency this function might run at. You should
283 * use SDL's timer functions if you need to see how much time has passed since
284 * the last iteration.
285 *
286 * There is no need to process the SDL event queue during this function; SDL
287 * will send events as they arrive in SDL_AppEvent, and in most cases the
288 * event queue will be empty when this function runs anyhow.
289 *
290 * This function should not go into an infinite mainloop; it should do one
291 * iteration of whatever the program does and return.
292 *
293 * The `appstate` parameter is an optional pointer provided by the app during
294 * SDL_AppInit(). If the app never provided a pointer, this will be NULL.
295 *
296 * If this function returns SDL_APP_CONTINUE, the app will continue normal
297 * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
298 * the life of the program. If this function returns SDL_APP_FAILURE, SDL will
299 * call SDL_AppQuit and terminate the process with an exit code that reports
300 * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
301 * SDL_AppQuit and terminates with an exit code that reports success to the
302 * platform.
303 *
304 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
305 * \returns SDL_APP_FAILURE to terminate with an error, SDL_APP_SUCCESS to
306 * terminate with success, SDL_APP_CONTINUE to continue.
307 *
308 * \threadsafety This function is not thread safe.
309 *
310 * \since This function is available since SDL 3.0.0.
311 *
312 * \sa SDL_AppInit
313 * \sa SDL_AppEvent
314 */
315extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppIterate(void *appstate);
316
317/**
318 * App-implemented event entry point for SDL_MAIN_USE_CALLBACKS apps.
319 *
320 * Apps implement this function when using SDL_MAIN_USE_CALLBACKS. If using a
321 * standard "main" function, you should not supply this.
322 *
323 * This function is called as needed by SDL after SDL_AppInit returns 0; It is
324 * called once for each new event.
325 *
326 * There is (currently) no guarantee about what thread this will be called
327 * from; whatever thread pushes an event onto SDL's queue will trigger this
328 * function. SDL is responsible for pumping the event queue between each call
329 * to SDL_AppIterate, so in normal operation one should only get events in a
330 * serial fashion, but be careful if you have a thread that explicitly calls
331 * SDL_PushEvent.
332 *
333 * Events sent to this function are not owned by the app; if you need to save
334 * the data, you should copy it.
335 *
336 * This function should not go into an infinite mainloop; it should handle the
337 * provided event appropriately and return.
338 *
339 * The `appstate` parameter is an optional pointer provided by the app during
340 * SDL_AppInit(). If the app never provided a pointer, this will be NULL.
341 *
342 * If this function returns SDL_APP_CONTINUE, the app will continue normal
343 * operation, receiving repeated calls to SDL_AppIterate and SDL_AppEvent for
344 * the life of the program. If this function returns SDL_APP_FAILURE, SDL will
345 * call SDL_AppQuit and terminate the process with an exit code that reports
346 * an error to the platform. If it returns SDL_APP_SUCCESS, SDL calls
347 * SDL_AppQuit and terminates with an exit code that reports success to the
348 * platform.
349 *
350 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
351 * \param event the new event for the app to examine.
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_AppIterate
361 */
362extern SDLMAIN_DECLSPEC SDL_AppResult SDLCALL SDL_AppEvent(void *appstate, const SDL_Event *event);
363
364/**
365 * App-implemented deinit 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 once by SDL before terminating the program.
371 *
372 * This function will be called no matter what, even if SDL_AppInit requests
373 * termination.
374 *
375 * This function should not go into an infinite mainloop; it should
376 * deinitialize any resources necessary, perform whatever shutdown activities,
377 * and return.
378 *
379 * You do not need to call SDL_Quit() in this function, as SDL will call it
380 * after this function returns and before the process terminates, but it is
381 * safe to do so.
382 *
383 * The `appstate` parameter is an optional pointer provided by the app during
384 * SDL_AppInit(). If the app never provided a pointer, this will be NULL. This
385 * function call is the last time this pointer will be provided, so any
386 * resources to it should be cleaned up here.
387 *
388 * \param appstate an optional pointer, provided by the app in SDL_AppInit.
389 *
390 * \threadsafety This function is not thread safe.
391 *
392 * \since This function is available since SDL 3.0.0.
393 *
394 * \sa SDL_AppInit
395 */
396extern SDLMAIN_DECLSPEC void SDLCALL SDL_AppQuit(void *appstate);
397
398#endif /* SDL_MAIN_USE_CALLBACKS */
399
400
401/**
402 * The prototype for the application's main() function
403 *
404 * \param argc an ANSI-C style main function's argc.
405 * \param argv an ANSI-C style main function's argv.
406 * \returns an ANSI-C main return code; generally 0 is considered successful
407 * program completion, and small non-zero values are considered
408 * errors.
409 *
410 * \since This datatype is available since SDL 3.0.0.
411 */
412typedef int (SDLCALL *SDL_main_func)(int argc, char *argv[]);
413
414/**
415 * An app-supplied function for program entry.
416 *
417 * Apps do not directly create this function; they should create a standard
418 * ANSI-C `main` function instead. If SDL needs to insert some startup code
419 * before `main` runs, or the platform doesn't actually _use_ a function
420 * called "main", SDL will do some macro magic to redefine `main` to
421 * `SDL_main` and provide its own `main`.
422 *
423 * Apps should include `SDL_main.h` in the same file as their `main` function,
424 * and they should not use that symbol for anything else in that file, as it
425 * might get redefined.
426 *
427 * This function is only provided by the app if it isn't using
428 * SDL_MAIN_USE_CALLBACKS.
429 *
430 * Program startup is a surprisingly complex topic. Please see
431 * [README/main-functions](README/main-functions), (or
432 * docs/README-main-functions.md in the source tree) for a more detailed
433 * explanation.
434 *
435 * \param argc an ANSI-C style main function's argc.
436 * \param argv an ANSI-C style main function's argv.
437 * \returns an ANSI-C main return code; generally 0 is considered successful
438 * program completion, and small non-zero values are considered
439 * errors.
440 *
441 * \threadsafety This is the program entry point.
442 *
443 * \since This function is available since SDL 3.0.0.
444 */
445extern SDLMAIN_DECLSPEC int SDLCALL SDL_main(int argc, char *argv[]);
446
447/**
448 * Circumvent failure of SDL_Init() when not using SDL_main() as an entry
449 * point.
450 *
451 * This function is defined in SDL_main.h, along with the preprocessor rule to
452 * redefine main() as SDL_main(). Thus to ensure that your main() function
453 * will not be changed it is necessary to define SDL_MAIN_HANDLED before
454 * including SDL.h.
455 *
456 * \since This function is available since SDL 3.0.0.
457 *
458 * \sa SDL_Init
459 */
460extern SDL_DECLSPEC void SDLCALL SDL_SetMainReady(void);
461
462/**
463 * Initializes and launches an SDL application, by doing platform-specific
464 * initialization before calling your mainFunction and cleanups after it
465 * returns, if that is needed for a specific platform, otherwise it just calls
466 * mainFunction.
467 *
468 * You can use this if you want to use your own main() implementation without
469 * using SDL_main (like when using SDL_MAIN_HANDLED). When using this, you do
470 * *not* need SDL_SetMainReady().
471 *
472 * \param argc the argc parameter from the application's main() function, or 0
473 * if the platform's main-equivalent has no argc.
474 * \param argv the argv parameter from the application's main() function, or
475 * NULL if the platform's main-equivalent has no argv.
476 * \param mainFunction your SDL app's C-style main(). NOT the function you're
477 * calling this from! Its name doesn't matter; it doesn't
478 * literally have to be `main`.
479 * \param reserved should be NULL (reserved for future use, will probably be
480 * platform-specific then).
481 * \returns the return value from mainFunction: 0 on success, otherwise
482 * failure; SDL_GetError() might have more information on the
483 * failure.
484 *
485 * \threadsafety Generally this is called once, near startup, from the
486 * process's initial thread.
487 *
488 * \since This function is available since SDL 3.0.0.
489 */
490extern SDL_DECLSPEC int SDLCALL SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserved);
491
492/**
493 * An entry point for SDL's use in SDL_MAIN_USE_CALLBACKS.
494 *
495 * Generally, you should not call this function directly. This only exists to
496 * hand off work into SDL as soon as possible, where it has a lot more control
497 * and functionality available, and make the inline code in SDL_main.h as
498 * small as possible.
499 *
500 * Not all platforms use this, it's actual use is hidden in a magic
501 * header-only library, and you should not call this directly unless you
502 * _really_ know what you're doing.
503 *
504 * \param argc standard Unix main argc.
505 * \param argv standard Unix main argv.
506 * \param appinit the application's SDL_AppInit function.
507 * \param appiter the application's SDL_AppIterate function.
508 * \param appevent the application's SDL_AppEvent function.
509 * \param appquit the application's SDL_AppQuit function.
510 * \returns standard Unix main return value.
511 *
512 * \threadsafety It is not safe to call this anywhere except as the only
513 * function call in SDL_main.
514 *
515 * \since This function is available since SDL 3.0.0.
516 */
517extern 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);
518
519
520#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
521
522/**
523 * Register a win32 window class for SDL's use.
524 *
525 * This can be called to set the application window class at startup. It is
526 * safe to call this multiple times, as long as every call is eventually
527 * paired with a call to SDL_UnregisterApp, but a second registration attempt
528 * while a previous registration is still active will be ignored, other than
529 * to increment a counter.
530 *
531 * Most applications do not need to, and should not, call this directly; SDL
532 * will call it when initializing the video subsystem.
533 *
534 * \param name the window class name, in UTF-8 encoding. If NULL, SDL
535 * currently uses "SDL_app" but this isn't guaranteed.
536 * \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
537 * currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
538 * what is specified here.
539 * \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
540 * will use `GetModuleHandle(NULL)` instead.
541 * \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
542 * for more information.
543 *
544 * \since This function is available since SDL 3.0.0.
545 */
546extern SDL_DECLSPEC SDL_bool SDLCALL SDL_RegisterApp(const char *name, Uint32 style, void *hInst);
547
548/**
549 * Deregister the win32 window class from an SDL_RegisterApp call.
550 *
551 * This can be called to undo the effects of SDL_RegisterApp.
552 *
553 * Most applications do not need to, and should not, call this directly; SDL
554 * will call it when deinitializing the video subsystem.
555 *
556 * It is safe to call this multiple times, as long as every call is eventually
557 * paired with a prior call to SDL_RegisterApp. The window class will only be
558 * deregistered when the registration counter in SDL_RegisterApp decrements to
559 * zero through calls to this function.
560 *
561 * \since This function is available since SDL 3.0.0.
562 */
563extern SDL_DECLSPEC void SDLCALL SDL_UnregisterApp(void);
564
565#endif /* defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) */
566
567#ifdef SDL_PLATFORM_GDK
568
569/**
570 * Callback from the application to let the suspend continue.
571 *
572 * \since This function is available since SDL 3.0.0.
573 */
574extern SDL_DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
575
576#endif /* SDL_PLATFORM_GDK */
577
578#ifdef __cplusplus
579}
580#endif
581
582#include <SDL3/SDL_close_code.h>
583
584#if !defined(SDL_MAIN_HANDLED) && !defined(SDL_MAIN_NOIMPL)
585 /* include header-only SDL_main implementations */
586 #if defined(SDL_MAIN_USE_CALLBACKS) \
587 || defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_TVOS) \
588 || defined(SDL_PLATFORM_3DS) || defined(SDL_PLATFORM_NGAGE) || defined(SDL_PLATFORM_PS2) || defined(SDL_PLATFORM_PSP) \
589 || defined(SDL_PLATFORM_EMSCRIPTEN)
590
591 /* platforms which main (-equivalent) can be implemented in plain C */
592 #include <SDL3/SDL_main_impl.h>
593
594 #elif defined(SDL_PLATFORM_WINRT) /* C++ platforms */
595 #ifdef __cplusplus
596 #include <SDL3/SDL_main_impl.h>
597 #else
598 /* Note: to get rid of the following warning, you can #define SDL_MAIN_NOIMPL before including SDL_main.h
599 * 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()!
600 */
601 #ifdef _MSC_VER
602 #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>")
603 #elif defined(__GNUC__) /* gcc, clang, mingw and compatible are matched by this and have #warning */
604 #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>"
605 #endif /* __GNUC__ */
606 #endif /* __cplusplus */
607
608 #endif /* C++ platforms like SDL_PLATFORM_WINRT etc */
609#endif
610
611#endif /* SDL_main_h_ */
SDL_AppResult(* SDL_AppInit_func)(void **appstate, int argc, char *argv[])
Definition SDL_init.h:97
void(* SDL_AppQuit_func)(void *appstate)
Definition SDL_init.h:100
SDL_AppResult
Definition SDL_init.h:91
SDL_AppResult(* SDL_AppEvent_func)(void *appstate, const SDL_Event *event)
Definition SDL_init.h:99
SDL_AppResult(* SDL_AppIterate_func)(void *appstate)
Definition SDL_init.h:98
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:412
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)
uint32_t Uint32
Definition SDL_stdinc.h:268
bool SDL_bool
Definition SDL_stdinc.h:216