SDL_main.h 23 KB

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