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/* WIKI CATEGORY: Platform */
23
24/*
25 * SDL_platform_defines.h tries 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#ifndef __has_extension /* Older compilers don't support this */
69#define __has_extension(x) 0
70#include <TargetConditionals.h>
71#undef __has_extension
72#else
73#include <TargetConditionals.h>
74#endif
75
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#ifndef TARGET_OS_VISION
96#define TARGET_OS_VISION 0
97#endif
98
99#if TARGET_OS_TV
100#define SDL_PLATFORM_TVOS 1
101#endif
102#if TARGET_OS_VISION
103#define SDL_PLATFORM_VISIONOS 1
104#endif
105#if TARGET_OS_IPHONE
106#define SDL_PLATFORM_IOS 1
107#else
108#define SDL_PLATFORM_MACOS 1
109#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
110# error SDL for macOS only supports deploying on 10.7 and above.
111#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1070 */
112#endif /* TARGET_OS_IPHONE */
113#endif /* defined(SDL_PLATFORM_APPLE) */
114
115#ifdef __EMSCRIPTEN__
116#define SDL_PLATFORM_EMSCRIPTEN 1
117#endif
118#ifdef __NetBSD__
119#define SDL_PLATFORM_NETBSD 1
120#endif
121#ifdef __OpenBSD__
122#define SDL_PLATFORM_OPENBSD 1
123#endif
124#if defined(__OS2__) || defined(__EMX__)
125#define SDL_PLATFORM_OS2 1
126#endif
127#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
128#define SDL_PLATFORM_OSF 1
129#endif
130#ifdef __QNXNTO__
131#define SDL_PLATFORM_QNXNTO 1
132#endif
133#if defined(riscos) || defined(__riscos) || defined(__riscos__)
134#define SDL_PLATFORM_RISCOS 1
135#endif
136#if defined(__sun) && defined(__SVR4)
137#define SDL_PLATFORM_SOLARIS 1
138#endif
139
140#if defined(__CYGWIN__)
141#define SDL_PLATFORM_CYGWIN 1
142#endif
143
144#if defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN)
145#define SDL_PLATFORM_WINDOWS 1 /* Win32 api and Windows-based OSs */
146
147/* Try to find out if we're compiling for WinRT, GDK or non-WinRT/GDK */
148#if defined(_MSC_VER) && defined(__has_include)
149#if __has_include(<winapifamily.h>)
150#define HAVE_WINAPIFAMILY_H 1
151#else
152#define HAVE_WINAPIFAMILY_H 0
153#endif
154
155/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */
156#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */
157#define HAVE_WINAPIFAMILY_H 1
158#else
159#define HAVE_WINAPIFAMILY_H 0
160#endif
161
162#if HAVE_WINAPIFAMILY_H
163#include <winapifamily.h>
164#define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP))
165#else
166#define WINAPI_FAMILY_WINRT 0
167#endif /* HAVE_WINAPIFAMILY_H */
168
169#if HAVE_WINAPIFAMILY_H && HAVE_WINAPIFAMILY_H
170#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
171#else
172#define SDL_WINAPI_FAMILY_PHONE 0
173#endif
174
175#if WINAPI_FAMILY_WINRT
176#define SDL_PLATFORM_WINRT 1
177#elif defined(_GAMING_DESKTOP) /* GDK project configuration always defines _GAMING_XXX */
178#define SDL_PLATFORM_WINGDK 1
179#elif defined(_GAMING_XBOX_XBOXONE)
180#define SDL_PLATFORM_XBOXONE 1
181#elif defined(_GAMING_XBOX_SCARLETT)
182#define SDL_PLATFORM_XBOXSERIES 1
183#else
184#define SDL_PLATFORM_WIN32 1
185#endif
186#endif /* defined(WIN32) || defined(_WIN32) || defined(SDL_PLATFORM_CYGWIN) */
187
188/* This is to support generic "any GDK" separate from a platform-specific GDK */
189#if defined(SDL_PLATFORM_WINGDK) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
190#define SDL_PLATFORM_GDK 1
191#endif
192#if defined(__PSP__) || defined(__psp__)
193#define SDL_PLATFORM_PSP 1
194#endif
195#if defined(__PS2__) || defined(PS2)
196#define SDL_PLATFORM_PS2 1
197#endif
198
199#if defined(__vita__) || defined(__psp2__)
200#define SDL_PLATFORM_VITA 1
201#endif
202
203#ifdef __3DS__
204#undef __3DS__
205#define SDL_PLATFORM_3DS 1
206#endif
207
208#endif /* SDL_platform_defines_h_ */