SDL_platform_defines.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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. * 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_XR
  81. #define TARGET_OS_XR 0
  82. #endif
  83. #if TARGET_OS_TV
  84. #define SDL_PLATFORM_TVOS 1
  85. #endif
  86. #if TARGET_OS_IPHONE
  87. #define SDL_PLATFORM_IOS 1
  88. #else
  89. #define SDL_PLATFORM_MACOS 1
  90. #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
  91. # error SDL for macOS only supports deploying on 10.7 and above.
  92. #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
  93. #endif /* TARGET_OS_IPHONE */
  94. #endif /* defined(SDL_PLATFORM_APPLE) */
  95. #ifdef __EMSCRIPTEN__
  96. #define SDL_PLATFORM_EMSCRIPTEN 1
  97. #endif
  98. #ifdef __NetBSD__
  99. #define SDL_PLATFORM_NETBSD 1
  100. #endif
  101. #ifdef __OpenBSD__
  102. #define SDL_PLATFORM_OPENBSD 1
  103. #endif
  104. #if defined(__OS2__) || defined(__EMX__)
  105. #define SDL_PLATFORM_OS2 1
  106. #endif
  107. #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
  108. #define SDL_PLATFORM_OSF 1
  109. #endif
  110. #ifdef __QNXNTO__
  111. #define SDL_PLATFORM_QNXNTO 1
  112. #endif
  113. #if defined(riscos) || defined(__riscos) || defined(__riscos__)
  114. #define SDL_PLATFORM_RISCOS 1
  115. #endif
  116. #if defined(__sun) && defined(__SVR4)
  117. #define SDL_PLATFORM_SOLARIS 1
  118. #endif
  119. #if defined(__CYGWIN__)
  120. #define SDL_PLATFORM_CYGWIN 1
  121. #endif
  122. #if defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)
  123. #define SDL_PLATFORM_WINDOWS 1 /* Win32 api and Windows-based OSs */
  124. /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
  125. #if defined(_MSC_VER) && defined(__has_include)
  126. #if __has_include(<winapifamily.h>)
  127. #define HAVE_WINAPIFAMILY_H 1
  128. #else
  129. #define HAVE_WINAPIFAMILY_H 0
  130. #endif
  131. /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
  132. #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
  133. #define HAVE_WINAPIFAMILY_H 1
  134. #else
  135. #define HAVE_WINAPIFAMILY_H 0
  136. #endif
  137. #if HAVE_WINAPIFAMILY_H
  138. #include <winapifamily.h>
  139. #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
  140. #else
  141. #define WINAPI_FAMILY_WINRT 0
  142. #endif /* HAVE_WINAPIFAMILY_H */
  143. #if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H
  144. #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
  145. #else
  146. #define SDL_WINAPI_FAMILY_PHONE 0
  147. #endif
  148. #if WINAPI_FAMILY_WINRT
  149. #define SDL_PLATFORM_WINRT 1
  150. #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
  151. #define SDL_PLATFORM_WINGDK 1
  152. #elif defined(_GAMING_XBOX_XBOXONE)
  153. #define SDL_PLATFORM_XBOXONE 1
  154. #elif defined(_GAMING_XBOX_SCARLETT)
  155. #define SDL_PLATFORM_XBOXSERIES 1
  156. #else
  157. #define SDL_PLATFORM_WIN32 1
  158. #endif
  159. #endif /* defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */
  160. /* This is to support generic "any GDK" separate from a platform-specific GDK */
  161. #if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
  162. #define SDL_PLATFORM_GDK 1
  163. #endif
  164. #ifdef __PSP__
  165. #define SDL_PLATFORM_PSP 1
  166. #endif
  167. #if defined(__PS2__) || defined(PS2)
  168. #define SDL_PLATFORM_PS2 1
  169. #endif
  170. #if defined(__vita__) || defined(__psp2__)
  171. #define SDL_PLATFORM_VITA 1
  172. #endif
  173. #ifdef __3DS__
  174. #undef __3DS__
  175. #define SDL_PLATFORM_3DS 1
  176. #endif
  177. #endif /* SDL_platform_defines_h_ */