begin_code.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2016 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. /**
  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. //Mark was here! Prevents SDL generating dll funcs.
  31. #define DECLSPEC
  32. #ifndef SDL_DEPRECATED
  33. # if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
  34. # define SDL_DEPRECATED __attribute__((deprecated))
  35. # else
  36. # define SDL_DEPRECATED
  37. # endif
  38. #endif
  39. #ifndef SDL_UNUSED
  40. # ifdef __GNUC__
  41. # define SDL_UNUSED __attribute__((unused))
  42. # else
  43. # define SDL_UNUSED
  44. # endif
  45. #endif
  46. /* Some compilers use a special export keyword */
  47. #ifndef DECLSPEC
  48. # if defined(__WIN32__) || defined(__WINRT__)
  49. # ifdef __BORLANDC__
  50. # ifdef BUILD_SDL
  51. # define DECLSPEC
  52. # else
  53. # define DECLSPEC __declspec(dllimport)
  54. # endif
  55. # else
  56. # define DECLSPEC __declspec(dllexport)
  57. # endif
  58. # else
  59. # if defined(__GNUC__) && __GNUC__ >= 4
  60. # define DECLSPEC __attribute__ ((visibility("default")))
  61. # else
  62. # define DECLSPEC
  63. # endif
  64. # endif
  65. #endif
  66. /* By default SDL uses the C calling convention */
  67. #ifndef SDLCALL
  68. #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__)
  69. #define SDLCALL __cdecl
  70. #else
  71. #define SDLCALL
  72. #endif
  73. #endif /* SDLCALL */
  74. /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */
  75. #ifdef __SYMBIAN32__
  76. #undef DECLSPEC
  77. #define DECLSPEC
  78. #endif /* __SYMBIAN32__ */
  79. /* Force structure packing at 4 byte alignment.
  80. This is necessary if the header is included in code which has structure
  81. packing set to an alternate value, say for loading structures from disk.
  82. The packing is reset to the previous value in close_code.h
  83. */
  84. #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
  85. #ifdef _MSC_VER
  86. #pragma warning(disable: 4103)
  87. #endif
  88. #ifdef __BORLANDC__
  89. #pragma nopackwarning
  90. #endif
  91. #ifdef _M_X64
  92. /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
  93. #pragma pack(push,8)
  94. #else
  95. #pragma pack(push,4)
  96. #endif
  97. #endif /* Compiler needs structure packing set */
  98. #ifndef SDL_INLINE
  99. #if defined(__GNUC__)
  100. #define SDL_INLINE __inline__
  101. #elif defined(_MSC_VER) || defined(__BORLANDC__) || \
  102. defined(__DMC__) || defined(__SC__) || \
  103. defined(__WATCOMC__) || defined(__LCC__) || \
  104. defined(__DECC)
  105. #define SDL_INLINE __inline
  106. #ifndef __inline__
  107. #define __inline__ __inline
  108. #endif
  109. #else
  110. #define SDL_INLINE inline
  111. #ifndef __inline__
  112. #define __inline__ inline
  113. #endif
  114. #endif
  115. #endif /* SDL_INLINE not defined */
  116. #ifndef SDL_FORCE_INLINE
  117. #if defined(_MSC_VER)
  118. #define SDL_FORCE_INLINE __forceinline
  119. #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
  120. #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
  121. #else
  122. #define SDL_FORCE_INLINE static SDL_INLINE
  123. #endif
  124. #endif /* SDL_FORCE_INLINE not defined */
  125. #ifndef SDL_NORETURN
  126. #if defined(__GNUC__)
  127. #define SDL_NORETURN __attribute__((noreturn))
  128. #elif defined(_MSC_VER)
  129. #define SDL_NORETURN __declspec(noreturn)
  130. #else
  131. #define SDL_NORETURN
  132. #endif
  133. #endif /* SDL_NORETURN not defined */
  134. /* Apparently this is needed by several Windows compilers */
  135. #if !defined(__MACH__)
  136. #ifndef NULL
  137. #ifdef __cplusplus
  138. #define NULL 0
  139. #else
  140. #define NULL ((void *)0)
  141. #endif
  142. #endif /* NULL */
  143. #endif /* ! Mac OS X - breaks precompiled headers */