SDL_platform_defines.h 5.8 KB

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