SDL_main.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2013 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. The file, src/main/winrt/SDL_WinRT_main.cpp, or a copy
  38. of it, must be compiled into the app itself.
  39. */
  40. #define SDL_MAIN_NEEDED
  41. #elif defined(__IPHONEOS__)
  42. /* On iOS SDL provides a main function that creates an application delegate
  43. and starts the iOS application run loop.
  44. See src/video/uikit/SDL_uikitappdelegate.m for more details.
  45. */
  46. #define SDL_MAIN_NEEDED
  47. #elif defined(__ANDROID__)
  48. /* On Android SDL provides a Java class in SDLActivity.java that is the
  49. main activity entry point.
  50. See README-android.txt for more details on extending that class.
  51. */
  52. #define SDL_MAIN_NEEDED
  53. #endif
  54. #endif /* SDL_MAIN_HANDLED */
  55. #ifdef __cplusplus
  56. #define C_LINKAGE "C"
  57. #else
  58. #define C_LINKAGE
  59. #endif /* __cplusplus */
  60. /**
  61. * \file SDL_main.h
  62. *
  63. * The application's main() function must be called with C linkage,
  64. * and should be declared like this:
  65. * \code
  66. * #ifdef __cplusplus
  67. * extern "C"
  68. * #endif
  69. * int main(int argc, char *argv[])
  70. * {
  71. * }
  72. * \endcode
  73. */
  74. #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
  75. #define main SDL_main
  76. #endif
  77. /**
  78. * The prototype for the application's main() function
  79. */
  80. extern C_LINKAGE int SDL_main(int argc, char *argv[]);
  81. #include "begin_code.h"
  82. #ifdef __cplusplus
  83. extern "C" {
  84. #endif
  85. /*
  86. * This is called by the real SDL main function to let the rest of the
  87. * library know that initialization was done properly.
  88. *
  89. * Calling this yourself without knowing what you're doing can cause
  90. * crashes and hard to diagnose problems with your application.
  91. */
  92. extern DECLSPEC void SDL_SetMainReady(void);
  93. #ifdef __WIN32__
  94. /**
  95. * This can be called to set the application class at startup
  96. */
  97. extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style,
  98. void *hInst);
  99. extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
  100. #endif /* __WIN32__ */
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #include "close_code.h"
  105. #endif /* _SDL_main_h */
  106. /* vi: set ts=4 sw=4 expandtab: */