Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsystemdetection.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// Copyright (C) 2019 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#if 0
6#pragma qt_class(QtSystemDetection)
7#pragma qt_sync_skip_header_check
8#pragma qt_sync_stop_processing
9#endif
10
11#ifndef QSYSTEMDETECTION_H
12#define QSYSTEMDETECTION_H
13
14/*
15 The operating system, must be one of: (Q_OS_x)
16
17 DARWIN - Any Darwin system (macOS, iOS, watchOS, tvOS)
18 MACOS - macOS
19 IOS - iOS
20 WATCHOS - watchOS
21 TVOS - tvOS
22 VISIONOS - visionOS
23 WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
24 CYGWIN - Cygwin
25 SOLARIS - Sun Solaris
26 HPUX - HP-UX
27 LINUX - Linux [has variants]
28 FREEBSD - FreeBSD [has variants]
29 NETBSD - NetBSD
30 OPENBSD - OpenBSD
31 INTERIX - Interix
32 AIX - AIX
33 HURD - GNU Hurd
34 QNX - QNX [has variants]
35 QNX6 - QNX RTP 6.1
36 LYNX - LynxOS
37 BSD4 - Any BSD 4.4 system
38 UNIX - Any UNIX BSD/SYSV system
39 ANDROID - Android platform
40 HAIKU - Haiku
41 WEBOS - LG WebOS
42 WASM - WebAssembly
43
44 The following operating systems have variants:
45 LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android
46 - only Q_OS_LINUX is defined if building for other Linux systems
47 MACOS - both Q_OS_BSD4 and Q_OS_IOS are defined when building for iOS
48 - both Q_OS_BSD4 and Q_OS_MACOS are defined when building for macOS
49 FREEBSD - Q_OS_FREEBSD is defined only when building for FreeBSD with a BSD userland
50 - Q_OS_FREEBSD_KERNEL is always defined on FreeBSD, even if the userland is from GNU
51*/
52
53#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
54# include <TargetConditionals.h>
55# define Q_OS_APPLE
56# if defined(TARGET_OS_MAC) && TARGET_OS_MAC
57# define Q_OS_DARWIN
58# define Q_OS_BSD4
59# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
60# define QT_PLATFORM_UIKIT
61# if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
62# define Q_OS_WATCHOS
63# elif defined(TARGET_OS_TV) && TARGET_OS_TV
64# define Q_OS_TVOS
65# elif defined(TARGET_OS_VISION) && TARGET_OS_VISION
66# define Q_OS_VISIONOS
67# else
68# // TARGET_OS_IOS is only available in newer SDKs,
69# // so assume any other iOS-based platform is iOS for now
70# define Q_OS_IOS
71# endif
72# else
73# // TARGET_OS_OSX is only available in newer SDKs,
74# // so assume any non iOS-based platform is macOS for now
75# define Q_OS_MACOS
76# endif
77# else
78# error "Qt has not been ported to this Apple platform - see http://www.qt.io/developers"
79# endif
80#elif defined(__WEBOS__)
81# define Q_OS_WEBOS
82# define Q_OS_LINUX
83#elif defined(__ANDROID__) || defined(ANDROID)
84# define Q_OS_ANDROID
85# define Q_OS_LINUX
86#elif defined(__CYGWIN__)
87# define Q_OS_CYGWIN
88#elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
89# define Q_OS_WIN32
90# define Q_OS_WIN64
91#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
92# define Q_OS_WIN32
93#elif defined(__sun) || defined(sun)
94# define Q_OS_SOLARIS
95#elif defined(hpux) || defined(__hpux)
96# define Q_OS_HPUX
97#elif defined(__EMSCRIPTEN__)
98# define Q_OS_WASM
99#elif defined(__linux__) || defined(__linux)
100# define Q_OS_LINUX
101#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
102# ifndef __FreeBSD_kernel__
103# define Q_OS_FREEBSD
104# endif
105# define Q_OS_FREEBSD_KERNEL
106# define Q_OS_BSD4
107#elif defined(__NetBSD__)
108# define Q_OS_NETBSD
109# define Q_OS_BSD4
110#elif defined(__OpenBSD__)
111# define Q_OS_OPENBSD
112# define Q_OS_BSD4
113#elif defined(__INTERIX)
114# define Q_OS_INTERIX
115# define Q_OS_BSD4
116#elif defined(_AIX)
117# define Q_OS_AIX
118#elif defined(__Lynx__)
119# define Q_OS_LYNX
120#elif defined(__GNU__)
121# define Q_OS_HURD
122#elif defined(__QNXNTO__)
123# define Q_OS_QNX
124#elif defined(__INTEGRITY)
125# define Q_OS_INTEGRITY
126#elif defined(__rtems__)
127# define Q_OS_RTEMS
128#elif defined(__vxworks)
129# define Q_OS_VXWORKS
130#elif defined(__HAIKU__)
131# define Q_OS_HAIKU
132#elif defined(__MAKEDEPEND__)
133#else
134# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
135#endif
136
137#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
138# define Q_OS_WINDOWS
139# define Q_OS_WIN
140// On Windows, pointers to dllimport'ed variables are not constant expressions,
141// so to keep to certain initializations (like QMetaObject) constexpr, we need
142// to use functions instead.
143# define QT_NO_DATA_RELOCATION
144#endif
145
146#if defined(Q_OS_WIN)
147# undef Q_OS_UNIX
148#elif !defined(Q_OS_UNIX)
149# define Q_OS_UNIX
150#endif
151
152// Compatibility synonyms
153#ifdef Q_OS_DARWIN
154# pragma clang diagnostic push
155# pragma clang diagnostic ignored "-Wunknown-pragmas"
156# define Q_OS_MAC // FIXME: Deprecate
157# ifdef __LP64__
158# define Q_OS_DARWIN64
159# pragma clang deprecated(Q_OS_DARWIN64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
160# define Q_OS_MAC64
161# pragma clang deprecated(Q_OS_MAC64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
162# else
163# define Q_OS_DARWIN32
164# pragma clang deprecated(Q_OS_DARWIN32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
165# define Q_OS_MAC32
166# pragma clang deprecated(Q_OS_MAC32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
167# endif
168# ifdef Q_OS_MACOS
169# define Q_OS_MACX
170# pragma clang deprecated(Q_OS_MACX, "use Q_OS_MACOS instead")
171# define Q_OS_OSX
172# pragma clang deprecated(Q_OS_OSX, "use Q_OS_MACOS instead")
173# endif
174# pragma clang diagnostic pop
175#endif
176
177#ifdef Q_OS_DARWIN
178# include <Availability.h>
179# include <AvailabilityMacros.h>
180
181# define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) \
182 ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= macos) || \
183 (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) || \
184 (defined(__TV_OS_VERSION_MAX_ALLOWED) && tvos != __TVOS_NA && __TV_OS_VERSION_MAX_ALLOWED >= tvos) || \
185 (defined(__WATCH_OS_VERSION_MAX_ALLOWED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MAX_ALLOWED >= watchos))
186
187# define QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, tvos, watchos) \
188 ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < macos) || \
189 (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) || \
190 (defined(__TV_OS_VERSION_MIN_REQUIRED) && tvos != __TVOS_NA && __TV_OS_VERSION_MIN_REQUIRED < tvos) || \
191 (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MIN_REQUIRED < watchos))
192
193# define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) \
194 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, __TVOS_NA, __WATCHOS_NA)
195# define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) \
196 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
197# define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) \
198 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
199# define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) \
200 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
201# define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) \
202 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
203
204# define QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(macos, ios) \
205 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, __TVOS_NA, __WATCHOS_NA)
206# define QT_MACOS_DEPLOYMENT_TARGET_BELOW(macos) \
207 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
208# define QT_IOS_DEPLOYMENT_TARGET_BELOW(ios) \
209 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
210# define QT_TVOS_DEPLOYMENT_TARGET_BELOW(tvos) \
211 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
212# define QT_WATCHOS_DEPLOYMENT_TARGET_BELOW(watchos) \
213 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
214
215#else // !Q_OS_DARWIN
216
217#define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) (0)
218#define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) (0)
219#define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) (0)
220#define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) (0)
221#define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) (0)
222#define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) (0)
223
224#endif // Q_OS_DARWIN
225
226#ifdef __LSB_VERSION__
227# if __LSB_VERSION__ < 40
228# error "This version of the Linux Standard Base is unsupported"
229# endif
230#ifndef QT_LINUXBASE
231# define QT_LINUXBASE
232#endif
233#endif
234
235#if defined (__ELF__)
236# define Q_OF_ELF
237#endif
238#if defined (__MACH__) && defined (__APPLE__)
239# define Q_OF_MACH_O
240#endif
241
242#endif // QSYSTEMDETECTION_H