SDL_platform_defines.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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 SDL_platform_defines.h
  20. *
  21. * 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. #define SDL_PLATFORM_AIX 1
  27. #endif
  28. #ifdef __HAIKU__
  29. #define SDL_PLATFORM_HAIKU 1
  30. #endif
  31. #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
  32. #define SDL_PLATFORM_BSDI 1
  33. #endif
  34. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
  35. #define SDL_PLATFORM_FREEBSD 1
  36. #endif
  37. #if defined(hpux) || defined(__hpux) || defined(__hpux__)
  38. #define SDL_PLATFORM_HPUX 1
  39. #endif
  40. #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
  41. #define SDL_PLATFORM_IRIX 1
  42. #endif
  43. #if (defined(linux) || defined(__linux) || defined(__linux__))
  44. #define SDL_PLATFORM_LINUX 1
  45. #endif
  46. #if defined(ANDROID) || defined(__ANDROID__)
  47. #undef SDL_PLATFORM_LINUX /* do we need to do this? */
  48. #define SDL_PLATFORM_ANDROID 1
  49. #endif
  50. #ifdef __NGAGE__
  51. #define SDL_PLATFORM_NGAGE 1
  52. #endif
  53. #if defined(__unix__) || defined(__unix) || defined(unix)
  54. #define SDL_PLATFORM_UNIX 1
  55. #endif
  56. #ifdef __APPLE__
  57. #define SDL_PLATFORM_APPLE 1
  58. /* lets us know what version of macOS we're compiling on */
  59. #include <AvailabilityMacros.h>
  60. #include <TargetConditionals.h>
  61. /* Fix building with older SDKs that don't define these
  62. See this for more information:
  63. https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
  64. */
  65. #ifndef TARGET_OS_MACCATALYST
  66. #define TARGET_OS_MACCATALYST 0
  67. #endif
  68. #ifndef TARGET_OS_IOS
  69. #define TARGET_OS_IOS 0
  70. #endif
  71. #ifndef TARGET_OS_IPHONE
  72. #define TARGET_OS_IPHONE 0
  73. #endif
  74. #ifndef TARGET_OS_TV
  75. #define TARGET_OS_TV 0
  76. #endif
  77. #ifndef TARGET_OS_SIMULATOR
  78. #define TARGET_OS_SIMULATOR 0
  79. #endif
  80. #ifndef TARGET_OS_VISION
  81. #define TARGET_OS_VISION 0
  82. #endif
  83. #if TARGET_OS_TV
  84. #define SDL_PLATFORM_TVOS 1
  85. #endif
  86. #if TARGET_OS_VISION
  87. #define SDL_PLATFORM_VISIONOS 1
  88. #endif
  89. #if TARGET_OS_IPHONE
  90. #define SDL_PLATFORM_IOS 1
  91. #else
  92. #define SDL_PLATFORM_MACOS 1
  93. #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
  94. # error SDL for macOS only supports deploying on 10.7 and above.
  95. #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
  96. #endif /* TARGET_OS_IPHONE */
  97. #endif /* defined(SDL_PLATFORM_APPLE) */
  98. #ifdef __EMSCRIPTEN__
  99. #define SDL_PLATFORM_EMSCRIPTEN 1
  100. #endif
  101. #ifdef __NetBSD__
  102. #define SDL_PLATFORM_NETBSD 1
  103. #endif
  104. #ifdef __OpenBSD__
  105. #define SDL_PLATFORM_OPENBSD 1
  106. #endif
  107. #if defined(__OS2__) || defined(__EMX__)
  108. #define SDL_PLATFORM_OS2 1
  109. #endif
  110. #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
  111. #define SDL_PLATFORM_OSF 1
  112. #endif
  113. #ifdef __QNXNTO__
  114. #define SDL_PLATFORM_QNXNTO 1
  115. #endif
  116. #if defined(riscos) || defined(__riscos) || defined(__riscos__)
  117. #define SDL_PLATFORM_RISCOS 1
  118. #endif
  119. #if defined(__sun) && defined(__SVR4)
  120. #define SDL_PLATFORM_SOLARIS 1
  121. #endif
  122. #if defined(__CYGWIN__)
  123. #define SDL_PLATFORM_CYGWIN 1
  124. #endif
  125. #if defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)
  126. #define SDL_PLATFORM_WINDOWS 1 /* Win32 api and Windows-based OSs */
  127. /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
  128. #if defined(_MSC_VER) && defined(__has_include)
  129. #if __has_include(<winapifamily.h>)
  130. #define HAVE_WINAPIFAMILY_H 1
  131. #else
  132. #define HAVE_WINAPIFAMILY_H 0
  133. #endif
  134. /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
  135. #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
  136. #define HAVE_WINAPIFAMILY_H 1
  137. #else
  138. #define HAVE_WINAPIFAMILY_H 0
  139. #endif
  140. #if HAVE_WINAPIFAMILY_H
  141. #include <winapifamily.h>
  142. #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
  143. #else
  144. #define WINAPI_FAMILY_WINRT 0
  145. #endif /* HAVE_WINAPIFAMILY_H */
  146. #if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H
  147. #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
  148. #else
  149. #define SDL_WINAPI_FAMILY_PHONE 0
  150. #endif
  151. #if WINAPI_FAMILY_WINRT
  152. #define SDL_PLATFORM_WINRT 1
  153. #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
  154. #define SDL_PLATFORM_WINGDK 1
  155. #elif defined(_GAMING_XBOX_XBOXONE)
  156. #define SDL_PLATFORM_XBOXONE 1
  157. #elif defined(_GAMING_XBOX_SCARLETT)
  158. #define SDL_PLATFORM_XBOXSERIES 1
  159. #else
  160. #define SDL_PLATFORM_WIN32 1
  161. #endif
  162. #endif /* defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */
  163. /* This is to support generic "any GDK" separate from a platform-specific GDK */
  164. #if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
  165. #define SDL_PLATFORM_GDK 1
  166. #endif
  167. #ifdef __PSP__
  168. #define SDL_PLATFORM_PSP 1
  169. #endif
  170. #if defined(__PS2__) || defined(PS2)
  171. #define SDL_PLATFORM_PS2 1
  172. #endif
  173. #if defined(__vita__) || defined(__psp2__)
  174. #define SDL_PLATFORM_VITA 1
  175. #endif
  176. #ifdef __3DS__
  177. #undef __3DS__
  178. #define SDL_PLATFORM_3DS 1
  179. #endif
  180. #endif /* SDL_platform_defines_h_ */