SDL_platform_defines.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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. /**
  26. * A preprocessor macro that is only defined if compiling for AIX.
  27. *
  28. * \since This macro is available since SDL 3.1.3.
  29. */
  30. #define SDL_PLATFORM_AIX 1
  31. #endif
  32. #ifdef __HAIKU__
  33. /**
  34. * A preprocessor macro that is only defined if compiling for Haiku OS.
  35. *
  36. * \since This macro is available since SDL 3.1.3.
  37. */
  38. #define SDL_PLATFORM_HAIKU 1
  39. #endif
  40. #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
  41. /**
  42. * A preprocessor macro that is only defined if compiling for BSDi
  43. *
  44. * \since This macro is available since SDL 3.1.3.
  45. */
  46. #define SDL_PLATFORM_BSDI 1
  47. #endif
  48. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
  49. /**
  50. * A preprocessor macro that is only defined if compiling for FreeBSD.
  51. *
  52. * \since This macro is available since SDL 3.1.3.
  53. */
  54. #define SDL_PLATFORM_FREEBSD 1
  55. #endif
  56. #if defined(hpux) || defined(__hpux) || defined(__hpux__)
  57. /**
  58. * A preprocessor macro that is only defined if compiling for HP-UX.
  59. *
  60. * \since This macro is available since SDL 3.1.3.
  61. */
  62. #define SDL_PLATFORM_HPUX 1
  63. #endif
  64. #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
  65. /**
  66. * A preprocessor macro that is only defined if compiling for IRIX.
  67. *
  68. * \since This macro is available since SDL 3.1.3.
  69. */
  70. #define SDL_PLATFORM_IRIX 1
  71. #endif
  72. #if (defined(linux) || defined(__linux) || defined(__linux__))
  73. /**
  74. * A preprocessor macro that is only defined if compiling for Linux.
  75. *
  76. * Note that Android, although ostensibly a Linux-based system, will not
  77. * define this. It defines SDL_PLATFORM_ANDROID instead.
  78. *
  79. * \since This macro is available since SDL 3.1.3.
  80. */
  81. #define SDL_PLATFORM_LINUX 1
  82. #endif
  83. #if defined(ANDROID) || defined(__ANDROID__)
  84. /**
  85. * A preprocessor macro that is only defined if compiling for Android.
  86. *
  87. * \since This macro is available since SDL 3.1.3.
  88. */
  89. #define SDL_PLATFORM_ANDROID 1
  90. #undef SDL_PLATFORM_LINUX
  91. #endif
  92. #ifdef __NGAGE__
  93. /**
  94. * A preprocessor macro that is only defined if compiling for Nokia N-Gage.
  95. *
  96. * \since This macro is available since SDL 3.1.3.
  97. */
  98. #define SDL_PLATFORM_NGAGE 1
  99. #endif
  100. #if defined(__unix__) || defined(__unix) || defined(unix)
  101. /**
  102. * A preprocessor macro that is only defined if compiling for a Unix-like
  103. * system.
  104. *
  105. * Other platforms, like Linux, might define this in addition to their primary
  106. * define.
  107. *
  108. * \since This macro is available since SDL 3.1.3.
  109. */
  110. #define SDL_PLATFORM_UNIX 1
  111. #endif
  112. #ifdef __APPLE__
  113. /**
  114. * A preprocessor macro that is only defined if compiling for Apple platforms.
  115. *
  116. * iOS, macOS, etc will additionally define a more specific platform macro.
  117. *
  118. * \since This macro is available since SDL 3.1.3.
  119. *
  120. * \sa SDL_PLATFORM_MACOS
  121. * \sa SDL_PLATFORM_IOS
  122. * \sa SDL_PLATFORM_TVOS
  123. * \sa SDL_PLATFORM_VISIONOS
  124. */
  125. #define SDL_PLATFORM_APPLE 1
  126. /* lets us know what version of macOS we're compiling on */
  127. #include <AvailabilityMacros.h>
  128. #ifndef __has_extension /* Older compilers don't support this */
  129. #define __has_extension(x) 0
  130. #include <TargetConditionals.h>
  131. #undef __has_extension
  132. #else
  133. #include <TargetConditionals.h>
  134. #endif
  135. /* Fix building with older SDKs that don't define these
  136. See this for more information:
  137. https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
  138. */
  139. #ifndef TARGET_OS_MACCATALYST
  140. #define TARGET_OS_MACCATALYST 0
  141. #endif
  142. #ifndef TARGET_OS_IOS
  143. #define TARGET_OS_IOS 0
  144. #endif
  145. #ifndef TARGET_OS_IPHONE
  146. #define TARGET_OS_IPHONE 0
  147. #endif
  148. #ifndef TARGET_OS_TV
  149. #define TARGET_OS_TV 0
  150. #endif
  151. #ifndef TARGET_OS_SIMULATOR
  152. #define TARGET_OS_SIMULATOR 0
  153. #endif
  154. #ifndef TARGET_OS_VISION
  155. #define TARGET_OS_VISION 0
  156. #endif
  157. #if TARGET_OS_TV
  158. /**
  159. * A preprocessor macro that is only defined if compiling for tvOS.
  160. *
  161. * \since This macro is available since SDL 3.1.3.
  162. *
  163. * \sa SDL_PLATFORM_APPLE
  164. */
  165. #define SDL_PLATFORM_TVOS 1
  166. #endif
  167. #if TARGET_OS_VISION
  168. /**
  169. * A preprocessor macro that is only defined if compiling for VisionOS.
  170. *
  171. * \since This macro is available since SDL 3.1.3.
  172. *
  173. * \sa SDL_PLATFORM_APPLE
  174. */
  175. #define SDL_PLATFORM_VISIONOS 1
  176. #endif
  177. #if TARGET_OS_IPHONE
  178. /**
  179. * A preprocessor macro that is only defined if compiling for iOS.
  180. *
  181. * \since This macro is available since SDL 3.1.3.
  182. *
  183. * \sa SDL_PLATFORM_APPLE
  184. */
  185. #define SDL_PLATFORM_IOS 1
  186. #else
  187. /**
  188. * A preprocessor macro that is only defined if compiling for macOS.
  189. *
  190. * \since This macro is available since SDL 3.1.3.
  191. *
  192. * \sa SDL_PLATFORM_APPLE
  193. */
  194. #define SDL_PLATFORM_MACOS 1
  195. #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
  196. #error SDL for macOS only supports deploying on 10.7 and above.
  197. #endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
  198. #endif /* TARGET_OS_IPHONE */
  199. #endif /* defined(__APPLE__) */
  200. #ifdef __EMSCRIPTEN__
  201. /**
  202. * A preprocessor macro that is only defined if compiling for Emscripten.
  203. *
  204. * \since This macro is available since SDL 3.1.3.
  205. */
  206. #define SDL_PLATFORM_EMSCRIPTEN 1
  207. #endif
  208. #ifdef __NetBSD__
  209. /**
  210. * A preprocessor macro that is only defined if compiling for NetBSD.
  211. *
  212. * \since This macro is available since SDL 3.1.3.
  213. */
  214. #define SDL_PLATFORM_NETBSD 1
  215. #endif
  216. #ifdef __OpenBSD__
  217. /**
  218. * A preprocessor macro that is only defined if compiling for OpenBSD.
  219. *
  220. * \since This macro is available since SDL 3.1.3.
  221. */
  222. #define SDL_PLATFORM_OPENBSD 1
  223. #endif
  224. #if defined(__OS2__) || defined(__EMX__)
  225. /**
  226. * A preprocessor macro that is only defined if compiling for OS/2.
  227. *
  228. * \since This macro is available since SDL 3.1.3.
  229. */
  230. #define SDL_PLATFORM_OS2 1
  231. #endif
  232. #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
  233. /**
  234. * A preprocessor macro that is only defined if compiling for Tru64 (OSF/1).
  235. *
  236. * \since This macro is available since SDL 3.1.3.
  237. */
  238. #define SDL_PLATFORM_OSF 1
  239. #endif
  240. #ifdef __QNXNTO__
  241. /**
  242. * A preprocessor macro that is only defined if compiling for QNX Neutrino.
  243. *
  244. * \since This macro is available since SDL 3.1.3.
  245. */
  246. #define SDL_PLATFORM_QNXNTO 1
  247. #endif
  248. #if defined(riscos) || defined(__riscos) || defined(__riscos__)
  249. /**
  250. * A preprocessor macro that is only defined if compiling for RISC OS.
  251. *
  252. * \since This macro is available since SDL 3.1.3.
  253. */
  254. #define SDL_PLATFORM_RISCOS 1
  255. #endif
  256. #if defined(__sun) && defined(__SVR4)
  257. /**
  258. * A preprocessor macro that is only defined if compiling for SunOS/Solaris.
  259. *
  260. * \since This macro is available since SDL 3.1.3.
  261. */
  262. #define SDL_PLATFORM_SOLARIS 1
  263. #endif
  264. #if defined(__CYGWIN__)
  265. /**
  266. * A preprocessor macro that is only defined if compiling for Cygwin.
  267. *
  268. * \since This macro is available since SDL 3.1.3.
  269. */
  270. #define SDL_PLATFORM_CYGWIN 1
  271. #endif
  272. #if defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)
  273. /**
  274. * A preprocessor macro that is only defined if compiling for Windows.
  275. *
  276. * This also covers several other platforms, like Microsoft GDK, Xbox, WinRT,
  277. * etc. Each will have their own more-specific platform macros, too.
  278. *
  279. * \since This macro is available since SDL 3.1.3.
  280. *
  281. * \sa SDL_PLATFORM_WIN32
  282. * \sa SDL_PLATFORM_XBOXONE
  283. * \sa SDL_PLATFORM_XBOXSERIES
  284. * \sa SDL_PLATFORM_WINGDK
  285. * \sa SDL_PLATFORM_GDK
  286. */
  287. #define SDL_PLATFORM_WINDOWS 1
  288. /* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
  289. #if defined(_MSC_VER) && defined(__has_include)
  290. #if __has_include(<winapifamily.h>)
  291. #define HAVE_WINAPIFAMILY_H 1
  292. #else
  293. #define HAVE_WINAPIFAMILY_H 0
  294. #endif
  295. /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
  296. #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
  297. #define HAVE_WINAPIFAMILY_H 1
  298. #else
  299. #define HAVE_WINAPIFAMILY_H 0
  300. #endif
  301. #if HAVE_WINAPIFAMILY_H
  302. #include <winapifamily.h>
  303. #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
  304. #else
  305. #define WINAPI_FAMILY_WINRT 0
  306. #endif /* HAVE_WINAPIFAMILY_H */
  307. #if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H
  308. #define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
  309. #else
  310. #define SDL_WINAPI_FAMILY_PHONE 0
  311. #endif
  312. #if WINAPI_FAMILY_WINRT
  313. #error Windows RT/UWP is no longer supported in SDL
  314. #elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
  315. /**
  316. * A preprocessor macro that is only defined if compiling for Microsoft GDK
  317. * for Windows.
  318. *
  319. * \since This macro is available since SDL 3.1.3.
  320. */
  321. #define SDL_PLATFORM_WINGDK 1
  322. #elif defined(_GAMING_XBOX_XBOXONE)
  323. /**
  324. * A preprocessor macro that is only defined if compiling for Xbox One.
  325. *
  326. * \since This macro is available since SDL 3.1.3.
  327. */
  328. #define SDL_PLATFORM_XBOXONE 1
  329. #elif defined(_GAMING_XBOX_SCARLETT)
  330. /**
  331. * A preprocessor macro that is only defined if compiling for Xbox Series.
  332. *
  333. * \since This macro is available since SDL 3.1.3.
  334. */
  335. #define SDL_PLATFORM_XBOXSERIES 1
  336. #else
  337. /**
  338. * A preprocessor macro that is only defined if compiling for desktop Windows.
  339. *
  340. * Despite the "32", this also covers 64-bit Windows; as an informal
  341. * convention, its system layer tends to still be referred to as "the Win32
  342. * API."
  343. *
  344. * \since This macro is available since SDL 3.1.3.
  345. */
  346. #define SDL_PLATFORM_WIN32 1
  347. #endif
  348. #endif /* defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */
  349. /* This is to support generic "any GDK" separate from a platform-specific GDK */
  350. #if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
  351. /**
  352. * A preprocessor macro that is only defined if compiling for Microsoft GDK on
  353. * any platform.
  354. *
  355. * \since This macro is available since SDL 3.1.3.
  356. */
  357. #define SDL_PLATFORM_GDK 1
  358. #endif
  359. #if defined(__PSP__) || defined(__psp__)
  360. /**
  361. * A preprocessor macro that is only defined if compiling for Sony PSP.
  362. *
  363. * \since This macro is available since SDL 3.1.3.
  364. */
  365. #define SDL_PLATFORM_PSP 1
  366. #endif
  367. #if defined(__PS2__) || defined(PS2)
  368. /**
  369. * A preprocessor macro that is only defined if compiling for Sony PlayStation
  370. * 2.
  371. *
  372. * \since This macro is available since SDL 3.1.3.
  373. */
  374. #define SDL_PLATFORM_PS2 1
  375. #endif
  376. #if defined(__vita__) || defined(__psp2__)
  377. /**
  378. * A preprocessor macro that is only defined if compiling for Sony Vita.
  379. *
  380. * \since This macro is available since SDL 3.1.3.
  381. */
  382. #define SDL_PLATFORM_VITA 1
  383. #endif
  384. #ifdef __3DS__
  385. /**
  386. * A preprocessor macro that is only defined if compiling for Nintendo 3DS.
  387. *
  388. * \since This macro is available since SDL 3.1.3.
  389. */
  390. #define SDL_PLATFORM_3DS 1
  391. #undef __3DS__
  392. #endif
  393. #endif /* SDL_platform_defines_h_ */