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