SDL 3.0
SDL_platform_defines.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/**
23 * \file SDL_platform_defines.h
24 *
25 * Try to get a standard set of platform defines.
26 */
27
28#ifndef SDL_platform_defines_h_
29#define SDL_platform_defines_h_
30
31#ifdef _AIX
32#define SDL_PLATFORM_AIX 1
33#endif
34#ifdef __HAIKU__
35#define SDL_PLATFORM_HAIKU 1
36#endif
37#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__)
38#define SDL_PLATFORM_BSDI 1
39#endif
40#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
41#define SDL_PLATFORM_FREEBSD 1
42#endif
43#if defined(hpux) || defined(__hpux) || defined(__hpux__)
44#define SDL_PLATFORM_HPUX 1
45#endif
46#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE)
47#define SDL_PLATFORM_IRIX 1
48#endif
49#if (defined(linux) || defined(__linux) || defined(__linux__))
50#define SDL_PLATFORM_LINUX 1
51#endif
52#if defined(ANDROID) || defined(__ANDROID__)
53#undef SDL_PLATFORM_LINUX /* do we need to do this? */
54#define SDL_PLATFORM_ANDROID 1
55#endif
56#ifdef __NGAGE__
57#define SDL_PLATFORM_NGAGE 1
58#endif
59
60#if defined(__unix__) || defined(__unix) || defined(unix)
61#define SDL_PLATFORM_UNIX 1
62#endif
63
64#ifdef __APPLE__
65#define SDL_PLATFORM_APPLE 1
66/* lets us know what version of macOS we're compiling on */
67#include <AvailabilityMacros.h>
68#include <TargetConditionals.h>
69
70/* Fix building with older SDKs that don't define these
71 See this for more information:
72 https://stackoverflow.com/questions/12132933/preprocessor-macro-for-os-x-targets
73*/
74#ifndef TARGET_OS_MACCATALYST
75#define TARGET_OS_MACCATALYST 0
76#endif
77#ifndef TARGET_OS_IOS
78#define TARGET_OS_IOS 0
79#endif
80#ifndef TARGET_OS_IPHONE
81#define TARGET_OS_IPHONE 0
82#endif
83#ifndef TARGET_OS_TV
84#define TARGET_OS_TV 0
85#endif
86#ifndef TARGET_OS_SIMULATOR
87#define TARGET_OS_SIMULATOR 0
88#endif
89#ifndef TARGET_OS_XR
90#define TARGET_OS_XR 0
91#endif
92
93#if TARGET_OS_TV
94#define SDL_PLATFORM_TVOS 1
95#endif
96#if TARGET_OS_IPHONE
97#define SDL_PLATFORM_IOS 1
98#else
99#define SDL_PLATFORM_MACOS 1
100#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
101# error SDL for macOS only supports deploying on 10.7 and above.
102#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
103#endif /* TARGET_OS_IPHONE */
104#endif /* defined(SDL_PLATFORM_APPLE) */
105
106#ifdef __EMSCRIPTEN__
107#define SDL_PLATFORM_EMSCRIPTEN 1
108#endif
109#ifdef __NetBSD__
110#define SDL_PLATFORM_NETBSD 1
111#endif
112#ifdef __OpenBSD__
113#define SDL_PLATFORM_OPENBSD 1
114#endif
115#if defined(__OS2__) || defined(__EMX__)
116#define SDL_PLATFORM_OS2 1
117#endif
118#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
119#define SDL_PLATFORM_OSF 1
120#endif
121#ifdef __QNXNTO__
122#define SDL_PLATFORM_QNXNTO 1
123#endif
124#if defined(riscos) || defined(__riscos) || defined(__riscos__)
125#define SDL_PLATFORM_RISCOS 1
126#endif
127#if defined(__sun) && defined(__SVR4)
128#define SDL_PLATFORM_SOLARIS 1
129#endif
130
131#if defined(__CYGWIN__)
132#define SDL_PLATFORM_CYGWIN 1
133#endif
134
135#if defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) || defined(__MINGW32__)
136/* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
137#if defined(_MSC_VER) && defined(__has_include)
138#if __has_include(<winapifamily.h>)
139#define HAVE_WINAPIFAMILY_H 1
140#else
141#define HAVE_WINAPIFAMILY_H 0
142#endif
143
144/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
145#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
146#define HAVE_WINAPIFAMILY_H 1
147#else
148#define HAVE_WINAPIFAMILY_H 0
149#endif
150
151#if HAVE_WINAPIFAMILY_H
152#include <winapifamily.h>
153#define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
154#else
155#define WINAPI_FAMILY_WINRT 0
156#endif /* HAVE_WINAPIFAMILY_H */
157
158#if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H
159#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
160#else
161#define SDL_WINAPI_FAMILY_PHONE 0
162#endif
163
164#if WINAPI_FAMILY_WINRT
165#define SDL_PLATFORM_WINRT 1
166#elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
167#define SDL_PLATFORM_WINGDK 1
168#elif defined(_GAMING_XBOX_XBOXONE)
169#define SDL_PLATFORM_XBOXONE 1
170#elif defined(_GAMING_XBOX_SCARLETT)
171#define SDL_PLATFORM_XBOXSERIES 1
172#else
173#define SDL_PLATFORM_WINDOWS 1
174#endif
175#endif /* defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */
176
177#ifdef SDL_PLATFORM_WINDOWS
178#define SDL_PLATFORM_WIN32 1
179#endif
180/* This is to support generic "any GDK" separate from a platform-specific GDK */
181#if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
182#define SDL_PLATFORM_GDK 1
183#endif
184#ifdef __PSP__
185#define SDL_PLATFORM_PSP 1
186#endif
187#if defined(__PS2__) || defined(PS2)
188#define SDL_PLATFORM_PS2 1
189#endif
190
191#if defined(__vita__) || defined(__psp2__)
192#define SDL_PLATFORM_VITA 1
193#endif
194
195#ifdef __3DS__
196#undef __3DS__
197#define SDL_PLATFORM_3DS 1
198#endif
199
200#endif /* SDL_platform_defines_h_ */