SDL_platform.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 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.h
  20. *
  21. * Try to get a standard set of platform defines.
  22. */
  23. #ifndef SDL_platform_h_
  24. #define SDL_platform_h_
  25. #if defined(_AIX)
  26. #undef __AIX__
  27. #define __AIX__ 1
  28. #endif
  29. #if defined(__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. #if defined(_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. #if defined(__NGAGE__)
  63. #undef __NGAGE__
  64. #define __NGAGE__ 1
  65. #endif
  66. #if defined(__APPLE__)
  67. /* lets us know what version of Mac OS X we're compiling on */
  68. #include <AvailabilityMacros.h>
  69. #ifndef __has_extension /* Older compilers don't support this */
  70. #define __has_extension(x) 0
  71. #include <TargetConditionals.h>
  72. #undef __has_extension
  73. #else
  74. #include <TargetConditionals.h>
  75. #endif
  76. /* Fix building with older SDKs that don't define these
  77. See this for more information:
  78. https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
  79. */
  80. #ifndef TARGET_OS_MACCATALYST
  81. #define TARGET_OS_MACCATALYST 0
  82. #endif
  83. #ifndef TARGET_OS_IOS
  84. #define TARGET_OS_IOS 0
  85. #endif
  86. #ifndef TARGET_OS_IPHONE
  87. #define TARGET_OS_IPHONE 0
  88. #endif
  89. #ifndef TARGET_OS_TV
  90. #define TARGET_OS_TV 0
  91. #endif
  92. #ifndef TARGET_OS_SIMULATOR
  93. #define TARGET_OS_SIMULATOR 0
  94. #endif
  95. #if TARGET_OS_TV
  96. #undef __TVOS__
  97. #define __TVOS__ 1
  98. #endif
  99. #if TARGET_OS_IPHONE
  100. /* if compiling for iOS */
  101. #undef __IPHONEOS__
  102. #define __IPHONEOS__ 1
  103. #undef __MACOSX__
  104. #else
  105. /* if not compiling for iOS */
  106. #undef __MACOSX__
  107. #define __MACOSX__ 1
  108. #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
  109. # error SDL for Mac OS X only supports deploying on 10.7 and above.
  110. #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
  111. #endif /* TARGET_OS_IPHONE */
  112. #endif /* defined(__APPLE__) */
  113. #if defined(__NetBSD__)
  114. #undef __NETBSD__
  115. #define __NETBSD__ 1
  116. #endif
  117. #if defined(__OpenBSD__)
  118. #undef __OPENBSD__
  119. #define __OPENBSD__ 1
  120. #endif
  121. #if defined(__OS2__) || defined(__EMX__)
  122. #undef __OS2__
  123. #define __OS2__ 1
  124. #endif
  125. #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
  126. #undef __OSF__
  127. #define __OSF__ 1
  128. #endif
  129. #if defined(__QNXNTO__)
  130. #undef __QNXNTO__
  131. #define __QNXNTO__ 1
  132. #endif
  133. #if defined(riscos) || defined(__riscos) || defined(__riscos__)
  134. #undef __RISCOS__
  135. #define __RISCOS__ 1
  136. #endif
  137. #if defined(__sun) && defined(__SVR4)
  138. #undef __SOLARIS__
  139. #define __SOLARIS__ 1
  140. #endif
  141. #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
  142. /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
  143. #if defined(_MSC_VER) && defined(__has_include)
  144. #if __has_include(<winapifamily.h>)
  145. #define HAVE_WINAPIFAMILY_H 1
  146. #else
  147. #define HAVE_WINAPIFAMILY_H 0
  148. #endif
  149. /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
  150. #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
  151. #define HAVE_WINAPIFAMILY_H 1
  152. #else
  153. #define HAVE_WINAPIFAMILY_H 0
  154. #endif
  155. #if HAVE_WINAPIFAMILY_H
  156. #include <winapifamily.h>
  157. #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
  158. #else
  159. #define WINAPI_FAMILY_WINRT 0
  160. #endif /* HAVE_WINAPIFAMILY_H */
  161. #if (HAVE_WINAPIFAMILY_H) && defined(WINAPI_FAMILY_PHONE_APP)
  162. #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
  163. #else
  164. #define SDL_WINAPI_FAMILY_PHONE 0
  165. #endif
  166. #if WINAPI_FAMILY_WINRT
  167. #undef __WINRT__
  168. #define __WINRT__ 1
  169. #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
  170. #undef __WINGDK__
  171. #define __WINGDK__ 1
  172. #elif defined(_GAMING_XBOX_XBOXONE)
  173. #undef __XBOXONE__
  174. #define __XBOXONE__ 1
  175. #elif defined(_GAMING_XBOX_SCARLETT)
  176. #undef __XBOXSERIES__
  177. #define __XBOXSERIES__ 1
  178. #else
  179. #undef __WINDOWS__
  180. #define __WINDOWS__ 1
  181. #endif
  182. #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
  183. #if defined(__WINDOWS__)
  184. #undef __WIN32__
  185. #define __WIN32__ 1
  186. #endif
  187. /* This is to support generic "any GDK" separate from a platform-specific GDK */
  188. #if defined(__WINGDK__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
  189. #undef __GDK__
  190. #define __GDK__ 1
  191. #endif
  192. #if defined(__PSP__) || defined(__psp__)
  193. #ifdef __PSP__
  194. #undef __PSP__
  195. #endif
  196. #define __PSP__ 1
  197. #endif
  198. #if defined(PS2)
  199. #define __PS2__ 1
  200. #endif
  201. /* The NACL compiler defines __native_client__ and __pnacl__
  202. * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
  203. */
  204. #if defined(__native_client__)
  205. #undef __LINUX__
  206. #undef __NACL__
  207. #define __NACL__ 1
  208. #endif
  209. #if defined(__pnacl__)
  210. #undef __LINUX__
  211. #undef __PNACL__
  212. #define __PNACL__ 1
  213. /* PNACL with newlib supports static linking only */
  214. #define __SDL_NOGETPROCADDR__
  215. #endif
  216. #if defined(__vita__)
  217. #define __VITA__ 1
  218. #endif
  219. #if defined(__3DS__)
  220. #undef __3DS__
  221. #define __3DS__ 1
  222. #endif
  223. #include "begin_code.h"
  224. /* Set up for C function definitions, even when using C++ */
  225. #ifdef __cplusplus
  226. extern "C" {
  227. #endif
  228. /**
  229. * Get the name of the platform.
  230. *
  231. * Here are the names returned for some (but not all) supported platforms:
  232. *
  233. * - "Windows"
  234. * - "Mac OS X"
  235. * - "Linux"
  236. * - "iOS"
  237. * - "Android"
  238. *
  239. * \returns the name of the platform. If the correct platform name is not
  240. * available, returns a string beginning with the text "Unknown".
  241. *
  242. * \since This function is available since SDL 2.0.0.
  243. */
  244. extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void);
  245. /* Ends C function definitions when using C++ */
  246. #ifdef __cplusplus
  247. }
  248. #endif
  249. #include "close_code.h"
  250. #endif /* SDL_platform_h_ */
  251. /* vi: set ts=4 sw=4 expandtab: */