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