SDL_main.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2009 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. Sam Lantinga
  16. slouken@libsdl.org
  17. */
  18. #ifndef _SDL_main_h
  19. #define _SDL_main_h
  20. #include "SDL_stdinc.h"
  21. /** @file SDL_main.h
  22. * Redefine main() on Win32 and MacOS so that it is called by winmain.c
  23. */
  24. #if defined(__WIN32__) || \
  25. (defined(__MWERKS__) && !defined(__BEOS__)) || \
  26. defined(__MACOS__) || defined(__MACOSX__) || \
  27. defined(__SYMBIAN32__) || defined(QWS)
  28. #ifdef __cplusplus
  29. #define C_LINKAGE "C"
  30. #else
  31. #define C_LINKAGE
  32. #endif /* __cplusplus */
  33. /** The application's main() function must be called with C linkage,
  34. * and should be declared like this:
  35. * @code
  36. * #ifdef __cplusplus
  37. * extern "C"
  38. * #endif
  39. * int main(int argc, char *argv[])
  40. * {
  41. * }
  42. * @endcode
  43. */
  44. #define main SDL_main
  45. /** The prototype for the application's main() function */
  46. extern C_LINKAGE int SDL_main(int argc, char *argv[]);
  47. /** @name From the SDL library code -- needed for registering the app on Win32 */
  48. /*@{*/
  49. #ifdef __WIN32__
  50. #include "begin_code.h"
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. /** This should be called from your WinMain() function, if any */
  55. extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
  56. /** This can also be called, but is no longer necessary */
  57. extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
  58. /** This can also be called, but is no longer necessary (SDL_Quit calls it) */
  59. extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #include "close_code.h"
  64. #endif
  65. /*@}*/
  66. /** @name From the SDL library code -- needed for registering QuickDraw on MacOS */
  67. /*@{*/
  68. #if defined(__MACOS__)
  69. #include "begin_code.h"
  70. #ifdef __cplusplus
  71. extern "C" {
  72. #endif
  73. /** Forward declaration so we don't need to include QuickDraw.h */
  74. struct QDGlobals;
  75. /** This should be called from your main() function, if any */
  76. extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #include "close_code.h"
  81. #endif
  82. /*@}*/
  83. #endif /* Need to redefine main()? */
  84. #endif /* _SDL_main_h */