SDL_platform_defines.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 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. /**
  19. * \file SDL_platform_defines.h
  20. *
  21. * \brief Try to get a standard set of platform defines.
  22. */
  23. #ifndef SDL_platform_defines_h_
  24. #define SDL_platform_defines_h_
  25. #ifdef _AIX
  26. #undef __AIX__
  27. #define __AIX__ 1
  28. #endif
  29. #ifdef __HAIKU__
  30. #undef __HAIKU__
  31. #define __HAIKU__ 1
  32. #endif
  33. #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
  34. #undef __BSDI__
  35. #define __BSDI__ 1
  36. #endif
  37. #ifdef _arch_dreamcast
  38. #undef __DREAMCAST__
  39. #define __DREAMCAST__ 1
  40. #endif
  41. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
  42. #undef __FREEBSD__
  43. #define __FREEBSD__ 1
  44. #endif
  45. #if defined(hpux) || defined(__hpux) || defined(__hpux__)
  46. #undef __HPUX__
  47. #define __HPUX__ 1
  48. #endif
  49. #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
  50. #undef __IRIX__
  51. #define __IRIX__ 1
  52. #endif
  53. #if (defined(linux) || defined(__linux) || defined(__linux__))
  54. #undef __LINUX__
  55. #define __LINUX__ 1
  56. #endif
  57. #if defined(ANDROID) || defined(__ANDROID__)
  58. #undef __ANDROID__
  59. #undef __LINUX__ /* do we need to do this? */
  60. #define __ANDROID__ 1
  61. #endif
  62. #ifdef __NGAGE__
  63. #undef __NGAGE__
  64. #define __NGAGE__ 1
  65. #endif
  66. #ifdef __APPLE__
  67. /* lets us know what version of macOS we're compiling on */
  68. #include <AvailabilityMacros.h>
  69. #include <TargetConditionals.h>
  70. /* Fix building with older SDKs that don't define these
  71. See this for more information:
  72. https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
  73. */
  74. #ifndef TARGET_OS_MACCATALYST
  75. #define TARGET_OS_MACCATALYST 0
  76. #endif
  77. #ifndef TARGET_OS_IOS
  78. #define TARGET_OS_IOS 0
  79. #endif
  80. #ifndef TARGET_OS_IPHONE
  81. #define TARGET_OS_IPHONE 0
  82. #endif
  83. #ifndef TARGET_OS_TV
  84. #define TARGET_OS_TV 0
  85. #endif
  86. #ifndef TARGET_OS_SIMULATOR
  87. #define TARGET_OS_SIMULATOR 0
  88. #endif
  89. #if TARGET_OS_TV
  90. #undef __TVOS__
  91. #define __TVOS__ 1
  92. #endif
  93. #if TARGET_OS_IPHONE
  94. #undef __IOS__
  95. #define __IOS__ 1
  96. #else
  97. #undef __MACOS__
  98. #define __MACOS__ 1
  99. #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
  100. # error SDL for macOS only supports deploying on 10.7 and above.
  101. #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
  102. #endif /* TARGET_OS_IPHONE */
  103. #endif /* defined(__APPLE__) */
  104. #ifdef __NetBSD__
  105. #undef __NETBSD__
  106. #define __NETBSD__ 1
  107. #endif
  108. #ifdef __OpenBSD__
  109. #undef __OPENBSD__
  110. #define __OPENBSD__ 1
  111. #endif
  112. #if defined(__OS2__) || defined(__EMX__)
  113. #undef __OS2__
  114. #define __OS2__ 1
  115. #endif
  116. #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
  117. #undef __OSF__
  118. #define __OSF__ 1
  119. #endif
  120. #ifdef __QNXNTO__
  121. #undef __QNXNTO__
  122. #define __QNXNTO__ 1
  123. #endif
  124. #if defined(riscos) || defined(__riscos) || defined(__riscos__)
  125. #undef __RISCOS__
  126. #define __RISCOS__ 1
  127. #endif
  128. #if defined(__sun) && defined(__SVR4)
  129. #undef __SOLARIS__
  130. #define __SOLARIS__ 1
  131. #endif
  132. #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
  133. /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
  134. #if defined(_MSC_VER) && defined(__has_include)
  135. #if __has_include(<winapifamily.h>)
  136. #define HAVE_WINAPIFAMILY_H 1
  137. #else
  138. #define HAVE_WINAPIFAMILY_H 0
  139. #endif
  140. /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
  141. #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
  142. #define HAVE_WINAPIFAMILY_H 1
  143. #else
  144. #define HAVE_WINAPIFAMILY_H 0
  145. #endif
  146. #if HAVE_WINAPIFAMILY_H
  147. #include <winapifamily.h>
  148. #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
  149. #else
  150. #define WINAPI_FAMILY_WINRT 0
  151. #endif /* HAVE_WINAPIFAMILY_H */
  152. #if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H
  153. #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
  154. #else
  155. #define SDL_WINAPI_FAMILY_PHONE 0
  156. #endif
  157. #if WINAPI_FAMILY_WINRT
  158. #undef __WINRT__
  159. #define __WINRT__ 1
  160. #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
  161. #undef __WINGDK__
  162. #define __WINGDK__ 1
  163. #elif defined(_GAMING_XBOX_XBOXONE)
  164. #undef __XBOXONE__
  165. #define __XBOXONE__ 1
  166. #elif defined(_GAMING_XBOX_SCARLETT)
  167. #undef __XBOXSERIES__
  168. #define __XBOXSERIES__ 1
  169. #else
  170. #undef __WINDOWS__
  171. #define __WINDOWS__ 1
  172. #endif
  173. #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
  174. #ifdef __WINDOWS__
  175. #undef __WIN32__
  176. #define __WIN32__ 1
  177. #endif
  178. /* This is to support generic "any GDK" separate from a platform-specific GDK */
  179. #if defined(__WINGDK__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
  180. #undef __GDK__
  181. #define __GDK__ 1
  182. #endif
  183. #ifdef __PSP__
  184. #undef __PSP__
  185. #define __PSP__ 1
  186. #endif
  187. #ifdef PS2
  188. #define __PS2__ 1
  189. #endif
  190. #ifdef __vita__
  191. #define __VITA__ 1
  192. #endif
  193. #ifdef __3DS__
  194. #undef __3DS__
  195. #define __3DS__ 1
  196. #endif
  197. #endif /* SDL_platform_defines_h_ */