begin_code.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. SDL - Simple DirectMedia Layer
  3. Copyright (C) 1997-2011 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. [email protected]
  17. */
  18. /**
  19. * \file begin_code.h
  20. *
  21. * This file sets things up for C dynamic library function definitions,
  22. * static inlined functions, and structures aligned at 4-byte alignment.
  23. * If you don't like ugly C preprocessor code, don't look at this file. :)
  24. */
  25. /* This shouldn't be nested -- included it around code only. */
  26. #ifdef _begin_code_h
  27. #error Nested inclusion of begin_code.h
  28. #endif
  29. #define _begin_code_h
  30. /* Some compilers use a special export keyword */
  31. #ifndef DECLSPEC
  32. # if defined(__BEOS__) || defined(__HAIKU__)
  33. # if defined(__GNUC__)
  34. # define DECLSPEC __declspec(dllexport)
  35. # else
  36. # define DECLSPEC __declspec(export)
  37. # endif
  38. # elif defined(__WIN32__)
  39. # ifdef __BORLANDC__
  40. # ifdef BUILD_SDL
  41. # define DECLSPEC
  42. # else
  43. # define DECLSPEC __declspec(dllimport)
  44. # endif
  45. # else
  46. # define DECLSPEC __declspec(dllexport)
  47. # endif
  48. # else
  49. # if defined(__GNUC__) && __GNUC__ >= 4
  50. # define DECLSPEC __attribute__ ((visibility("default")))
  51. # else
  52. # define DECLSPEC
  53. # endif
  54. # endif
  55. #endif
  56. /* By default SDL uses the C calling convention */
  57. #ifndef SDLCALL
  58. #if defined(__WIN32__) && !defined(__GNUC__)
  59. #define SDLCALL __cdecl
  60. #else
  61. #define SDLCALL
  62. #endif
  63. #endif /* SDLCALL */
  64. /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
  65. #ifdef __SYMBIAN32__
  66. #undef DECLSPEC
  67. #define DECLSPEC
  68. #endif /* __SYMBIAN32__ */
  69. /* Force structure packing at 4 byte alignment.
  70. This is necessary if the header is included in code which has structure
  71. packing set to an alternate value, say for loading structures from disk.
  72. The packing is reset to the previous value in close_code.h
  73. */
  74. #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
  75. #ifdef _MSC_VER
  76. #pragma warning(disable: 4103)
  77. #endif
  78. #ifdef __BORLANDC__
  79. #pragma nopackwarning
  80. #endif
  81. #pragma pack(push,4)
  82. #endif /* Compiler needs structure packing set */
  83. /* Set up compiler-specific options for inlining functions */
  84. #ifndef SDL_INLINE_OKAY
  85. #ifdef __GNUC__
  86. #define SDL_INLINE_OKAY
  87. #else
  88. /* Add any special compiler-specific cases here */
  89. #if defined(_MSC_VER) || defined(__BORLANDC__) || \
  90. defined(__DMC__) || defined(__SC__) || \
  91. defined(__WATCOMC__) || defined(__LCC__) || \
  92. defined(__DECC)
  93. #ifndef __inline__
  94. #define __inline__ __inline
  95. #endif
  96. #define SDL_INLINE_OKAY
  97. #else
  98. #if !defined(__MRC__) && !defined(_SGI_SOURCE)
  99. #ifndef __inline__
  100. #define __inline__ inline
  101. #endif
  102. #define SDL_INLINE_OKAY
  103. #endif /* Not a funky compiler */
  104. #endif /* Visual C++ */
  105. #endif /* GNU C */
  106. #endif /* SDL_INLINE_OKAY */
  107. /* If inlining isn't supported, remove "__inline__", turning static
  108. inlined functions into static functions (resulting in code bloat
  109. in all files which include the offending header files)
  110. */
  111. #ifndef SDL_INLINE_OKAY
  112. #define __inline__
  113. #endif
  114. /* Apparently this is needed by several Windows compilers */
  115. #if !defined(__MACH__)
  116. #ifndef NULL
  117. #ifdef __cplusplus
  118. #define NULL 0
  119. #else
  120. #define NULL ((void *)0)
  121. #endif
  122. #endif /* NULL */
  123. #endif /* ! Mac OS X - breaks precompiled headers */