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