🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
5.2 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  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 "SDL_stdinc.h"
  21. /**
  22. * \file SDL_main.h
  23. *
  24. * Redefine main() on some platforms so that it is called by SDL.
  25. */
  26. #ifndef SDL_MAIN_HANDLED
  27. #if defined(__WIN32__)
  28. /* On Windows SDL provides WinMain(), which parses the command line and passes
  29. the arguments to your main function.
  30. If you provide your own WinMain(), you may define SDL_MAIN_HANDLED
  31. */
  32. #define SDL_MAIN_AVAILABLE
  33. #elif defined(__WINRT__)
  34. /* On WinRT, SDL provides a main function that initializes CoreApplication,
  35. creating an instance of IFrameworkView in the process.
  36. Please note that #include'ing SDL_main.h is not enough to get a main()
  37. function working. In non-XAML apps, the file,
  38. src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled
  39. into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be
  40. called, with a pointer to the Direct3D-hosted XAML control passed in.
  41. */
  42. #define SDL_MAIN_NEEDED
  43. #elif defined(__IPHONEOS__)
  44. /* On iOS SDL provides a main function that creates an application delegate
  45. and starts the iOS application run loop.
  46. If you link with SDL dynamically on iOS, the main function can't be in a
  47. shared library, so you need to link with libSDLmain.a, which includes a
  48. stub main function that calls into the shared library to start execution.
  49. See src/video/uikit/SDL_uikitappdelegate.m for more details.
  50. */
  51. #define SDL_MAIN_NEEDED
  52. #elif defined(__ANDROID__)
  53. /* On Android SDL provides a Java class in SDLActivity.java that is the
  54. main activity entry point.
  55. See docs/README-android.md for more details on extending that class.
  56. */
  57. #define SDL_MAIN_NEEDED
  58. /* We need to export SDL_main so it can be launched from Java */
  59. #define SDLMAIN_DECLSPEC DECLSPEC
  60. #elif defined(__NACL__)
  61. /* On NACL we use ppapi_simple to set up the application helper code,
  62. then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before
  63. starting the user main function.
  64. All user code is run in a separate thread by ppapi_simple, thus
  65. allowing for blocking io to take place via nacl_io
  66. */
  67. #define SDL_MAIN_NEEDED
  68. #endif
  69. #endif /* SDL_MAIN_HANDLED */
  70. #ifndef SDLMAIN_DECLSPEC
  71. #define SDLMAIN_DECLSPEC
  72. #endif
  73. /**
  74. * \file SDL_main.h
  75. *
  76. * The application's main() function must be called with C linkage,
  77. * and should be declared like this:
  78. * \code
  79. * #ifdef __cplusplus
  80. * extern "C"
  81. * #endif
  82. * int main(int argc, char *argv[])
  83. * {
  84. * }
  85. * \endcode
  86. */
  87. #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
  88. #define main SDL_main
  89. #endif
  90. #include "begin_code.h"
  91. #ifdef __cplusplus
  92. extern "C" {
  93. #endif
  94. /**
  95. * The prototype for the application's main() function
  96. */
  97. typedef int (*SDL_main_func)(int argc, char *argv[]);
  98. extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
  99. /**
  100. * This is called by the real SDL main function to let the rest of the
  101. * library know that initialization was done properly.
  102. *
  103. * Calling this yourself without knowing what you're doing can cause
  104. * crashes and hard to diagnose problems with your application.
  105. */
  106. extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
  107. #ifdef __WIN32__
  108. /**
  109. * This can be called to set the application class at startup
  110. */
  111. extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
  112. extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
  113. #endif /* __WIN32__ */
  114. #ifdef __WINRT__
  115. /**
  116. * \brief Initializes and launches an SDL/WinRT application.
  117. *
  118. * \param mainFunction The SDL app's C-style main().
  119. * \param reserved Reserved for future use; should be NULL
  120. * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more
  121. * information on the failure.
  122. */
  123. extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved);
  124. #endif /* __WINRT__ */
  125. #if defined(__IPHONEOS__)
  126. /**
  127. * \brief Initializes and launches an SDL application.
  128. *
  129. * \param argc The argc parameter from the application's main() function
  130. * \param argv The argv parameter from the application's main() function
  131. * \param mainFunction The SDL app's C-style main().
  132. * \return the return value from mainFunction
  133. */
  134. extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction);
  135. #endif /* __IPHONEOS__ */
  136. #ifdef __cplusplus
  137. }
  138. #endif
  139. #include "close_code.h"
  140. #endif /* SDL_main_h_ */
  141. /* vi: set ts=4 sw=4 expandtab: */