Path: blob/master/thirdparty/sdl/include/SDL3/SDL_platform_defines.h
9912 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/* WIKI CATEGORY: Platform */2223/*24* SDL_platform_defines.h tries to get a standard set of platform defines.25*/2627#ifndef SDL_platform_defines_h_28#define SDL_platform_defines_h_2930#ifdef _AIX3132/**33* A preprocessor macro that is only defined if compiling for AIX.34*35* \since This macro is available since SDL 3.2.0.36*/37#define SDL_PLATFORM_AIX 138#endif3940#ifdef __HAIKU__4142/**43* A preprocessor macro that is only defined if compiling for Haiku OS.44*45* \since This macro is available since SDL 3.2.0.46*/47#define SDL_PLATFORM_HAIKU 148#endif4950#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)5152/**53* A preprocessor macro that is only defined if compiling for BSDi54*55* \since This macro is available since SDL 3.2.0.56*/57#define SDL_PLATFORM_BSDI 158#endif5960#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)6162/**63* A preprocessor macro that is only defined if compiling for FreeBSD.64*65* \since This macro is available since SDL 3.2.0.66*/67#define SDL_PLATFORM_FREEBSD 168#endif6970#if defined(hpux) || defined(__hpux) || defined(__hpux__)7172/**73* A preprocessor macro that is only defined if compiling for HP-UX.74*75* \since This macro is available since SDL 3.2.0.76*/77#define SDL_PLATFORM_HPUX 178#endif7980#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)8182/**83* A preprocessor macro that is only defined if compiling for IRIX.84*85* \since This macro is available since SDL 3.2.0.86*/87#define SDL_PLATFORM_IRIX 188#endif8990#if (defined(linux) || defined(__linux) || defined(__linux__))9192/**93* A preprocessor macro that is only defined if compiling for Linux.94*95* Note that Android, although ostensibly a Linux-based system, will not96* define this. It defines SDL_PLATFORM_ANDROID instead.97*98* \since This macro is available since SDL 3.2.0.99*/100#define SDL_PLATFORM_LINUX 1101#endif102103#if defined(ANDROID) || defined(__ANDROID__)104105/**106* A preprocessor macro that is only defined if compiling for Android.107*108* \since This macro is available since SDL 3.2.0.109*/110#define SDL_PLATFORM_ANDROID 1111#undef SDL_PLATFORM_LINUX112#endif113114#if defined(__unix__) || defined(__unix) || defined(unix)115116/**117* A preprocessor macro that is only defined if compiling for a Unix-like118* system.119*120* Other platforms, like Linux, might define this in addition to their primary121* define.122*123* \since This macro is available since SDL 3.2.0.124*/125#define SDL_PLATFORM_UNIX 1126#endif127128#ifdef __APPLE__129130/**131* A preprocessor macro that is only defined if compiling for Apple platforms.132*133* iOS, macOS, etc will additionally define a more specific platform macro.134*135* \since This macro is available since SDL 3.2.0.136*137* \sa SDL_PLATFORM_MACOS138* \sa SDL_PLATFORM_IOS139* \sa SDL_PLATFORM_TVOS140* \sa SDL_PLATFORM_VISIONOS141*/142#define SDL_PLATFORM_APPLE 1143144/* lets us know what version of macOS we're compiling on */145#include <AvailabilityMacros.h>146#ifndef __has_extension /* Older compilers don't support this */147#define __has_extension(x) 0148#include <TargetConditionals.h>149#undef __has_extension150#else151#include <TargetConditionals.h>152#endif153154/* Fix building with older SDKs that don't define these155See this for more information:156https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets157*/158#ifndef TARGET_OS_MACCATALYST159#define TARGET_OS_MACCATALYST 0160#endif161#ifndef TARGET_OS_IOS162#define TARGET_OS_IOS 0163#endif164#ifndef TARGET_OS_IPHONE165#define TARGET_OS_IPHONE 0166#endif167#ifndef TARGET_OS_TV168#define TARGET_OS_TV 0169#endif170#ifndef TARGET_OS_SIMULATOR171#define TARGET_OS_SIMULATOR 0172#endif173#ifndef TARGET_OS_VISION174#define TARGET_OS_VISION 0175#endif176177#if TARGET_OS_TV178179/**180* A preprocessor macro that is only defined if compiling for tvOS.181*182* \since This macro is available since SDL 3.2.0.183*184* \sa SDL_PLATFORM_APPLE185*/186#define SDL_PLATFORM_TVOS 1187#endif188189#if TARGET_OS_VISION190191/**192* A preprocessor macro that is only defined if compiling for VisionOS.193*194* \since This macro is available since SDL 3.2.0.195*196* \sa SDL_PLATFORM_APPLE197*/198#define SDL_PLATFORM_VISIONOS 1199#endif200201#if TARGET_OS_IPHONE202203/**204* A preprocessor macro that is only defined if compiling for iOS.205*206* \since This macro is available since SDL 3.2.0.207*208* \sa SDL_PLATFORM_APPLE209*/210#define SDL_PLATFORM_IOS 1211212#else213214/**215* A preprocessor macro that is only defined if compiling for macOS.216*217* \since This macro is available since SDL 3.2.0.218*219* \sa SDL_PLATFORM_APPLE220*/221#define SDL_PLATFORM_MACOS 1222223#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070224#error SDL for macOS only supports deploying on 10.7 and above.225#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */226#endif /* TARGET_OS_IPHONE */227#endif /* defined(__APPLE__) */228229#ifdef __EMSCRIPTEN__230231/**232* A preprocessor macro that is only defined if compiling for Emscripten.233*234* \since This macro is available since SDL 3.2.0.235*/236#define SDL_PLATFORM_EMSCRIPTEN 1237#endif238239#ifdef __NetBSD__240241/**242* A preprocessor macro that is only defined if compiling for NetBSD.243*244* \since This macro is available since SDL 3.2.0.245*/246#define SDL_PLATFORM_NETBSD 1247#endif248249#ifdef __OpenBSD__250251/**252* A preprocessor macro that is only defined if compiling for OpenBSD.253*254* \since This macro is available since SDL 3.2.0.255*/256#define SDL_PLATFORM_OPENBSD 1257#endif258259#if defined(__OS2__) || defined(__EMX__)260261/**262* A preprocessor macro that is only defined if compiling for OS/2.263*264* \since This macro is available since SDL 3.2.0.265*/266#define SDL_PLATFORM_OS2 1267#endif268269#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)270271/**272* A preprocessor macro that is only defined if compiling for Tru64 (OSF/1).273*274* \since This macro is available since SDL 3.2.0.275*/276#define SDL_PLATFORM_OSF 1277#endif278279#ifdef __QNXNTO__280281/**282* A preprocessor macro that is only defined if compiling for QNX Neutrino.283*284* \since This macro is available since SDL 3.2.0.285*/286#define SDL_PLATFORM_QNXNTO 1287#endif288289#if defined(riscos) || defined(__riscos) || defined(__riscos__)290291/**292* A preprocessor macro that is only defined if compiling for RISC OS.293*294* \since This macro is available since SDL 3.2.0.295*/296#define SDL_PLATFORM_RISCOS 1297#endif298299#if defined(__sun) && defined(__SVR4)300301/**302* A preprocessor macro that is only defined if compiling for SunOS/Solaris.303*304* \since This macro is available since SDL 3.2.0.305*/306#define SDL_PLATFORM_SOLARIS 1307#endif308309#if defined(__CYGWIN__)310311/**312* A preprocessor macro that is only defined if compiling for Cygwin.313*314* \since This macro is available since SDL 3.2.0.315*/316#define SDL_PLATFORM_CYGWIN 1317#endif318319#if defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)320321/**322* A preprocessor macro that is only defined if compiling for Windows.323*324* This also covers several other platforms, like Microsoft GDK, Xbox, WinRT,325* etc. Each will have their own more-specific platform macros, too.326*327* \since This macro is available since SDL 3.2.0.328*329* \sa SDL_PLATFORM_WIN32330* \sa SDL_PLATFORM_XBOXONE331* \sa SDL_PLATFORM_XBOXSERIES332* \sa SDL_PLATFORM_WINGDK333* \sa SDL_PLATFORM_GDK334*/335#define SDL_PLATFORM_WINDOWS 1336337/* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */338#if defined(_MSC_VER) && defined(__has_include)339#if __has_include(<winapifamily.h>)340#define HAVE_WINAPIFAMILY_H 1341#else342#define HAVE_WINAPIFAMILY_H 0343#endif344345/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */346#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */347#define HAVE_WINAPIFAMILY_H 1348#else349#define HAVE_WINAPIFAMILY_H 0350#endif351352#if HAVE_WINAPIFAMILY_H353#include <winapifamily.h>354#define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))355#else356#define WINAPI_FAMILY_WINRT 0357#endif /* HAVE_WINAPIFAMILY_H */358359#ifdef SDL_WIKI_DOCUMENTATION_SECTION360361/**362* A preprocessor macro that defined to 1 if compiling for Windows Phone.363*364* \since This macro is available since SDL 3.2.0.365*/366#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)367368#elif defined(HAVE_WINAPIFAMILY_H) && HAVE_WINAPIFAMILY_H369#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)370#else371#define SDL_WINAPI_FAMILY_PHONE 0372#endif373374#if WINAPI_FAMILY_WINRT375#error Windows RT/UWP is no longer supported in SDL376377#elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */378379/**380* A preprocessor macro that is only defined if compiling for Microsoft GDK381* for Windows.382*383* \since This macro is available since SDL 3.2.0.384*/385#define SDL_PLATFORM_WINGDK 1386387#elif defined(_GAMING_XBOX_XBOXONE)388389/**390* A preprocessor macro that is only defined if compiling for Xbox One.391*392* \since This macro is available since SDL 3.2.0.393*/394#define SDL_PLATFORM_XBOXONE 1395396#elif defined(_GAMING_XBOX_SCARLETT)397398/**399* A preprocessor macro that is only defined if compiling for Xbox Series.400*401* \since This macro is available since SDL 3.2.0.402*/403#define SDL_PLATFORM_XBOXSERIES 1404405#else406407/**408* A preprocessor macro that is only defined if compiling for desktop Windows.409*410* Despite the "32", this also covers 64-bit Windows; as an informal411* convention, its system layer tends to still be referred to as "the Win32412* API."413*414* \since This macro is available since SDL 3.2.0.415*/416#define SDL_PLATFORM_WIN32 1417418#endif419#endif /* defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */420421422/* This is to support generic "any GDK" separate from a platform-specific GDK */423#if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)424425/**426* A preprocessor macro that is only defined if compiling for Microsoft GDK on427* any platform.428*429* \since This macro is available since SDL 3.2.0.430*/431#define SDL_PLATFORM_GDK 1432#endif433434#if defined(__PSP__) || defined(__psp__)435436/**437* A preprocessor macro that is only defined if compiling for Sony PSP.438*439* \since This macro is available since SDL 3.2.0.440*/441#define SDL_PLATFORM_PSP 1442#endif443444#if defined(__PS2__) || defined(PS2)445446/**447* A preprocessor macro that is only defined if compiling for Sony PlayStation448* 2.449*450* \since This macro is available since SDL 3.2.0.451*/452#define SDL_PLATFORM_PS2 1453#endif454455#if defined(__vita__) || defined(__psp2__)456457/**458* A preprocessor macro that is only defined if compiling for Sony Vita.459*460* \since This macro is available since SDL 3.2.0.461*/462#define SDL_PLATFORM_VITA 1463#endif464465#ifdef __3DS__466467/**468* A preprocessor macro that is only defined if compiling for Nintendo 3DS.469*470* \since This macro is available since SDL 3.2.0.471*/472#define SDL_PLATFORM_3DS 1473#endif474475#endif /* SDL_platform_defines_h_ */476477478