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(__CYGWIN__)
88# define Q_OS_CYGWIN
89#elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
90# define Q_OS_WIN32
91# define Q_OS_WIN64
92#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
93# define Q_OS_WIN32
94#elif defined(__sun) || defined(sun)
95# define Q_OS_SOLARIS
96#elif defined(hpux) || defined(__hpux)
97# define Q_OS_HPUX
98#elif defined(__EMSCRIPTEN__)
99# define Q_OS_WASM
100#elif defined(__linux__) || defined(__linux)
101# define Q_OS_LINUX
102#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
103# ifndef __FreeBSD_kernel__
104# define Q_OS_FREEBSD
105# endif
106# define Q_OS_FREEBSD_KERNEL
107# define Q_OS_BSD4
108#elif defined(__NetBSD__)
109# define Q_OS_NETBSD
110# define Q_OS_BSD4
111#elif defined(__OpenBSD__)
112# define Q_OS_OPENBSD
113# define Q_OS_BSD4
114#elif defined(__INTERIX)
115# define Q_OS_INTERIX
116# define Q_OS_BSD4
117#elif defined(_AIX)
118# define Q_OS_AIX
119#elif defined(__Lynx__)
120# define Q_OS_LYNX
121#elif defined(__GNU__)
122# define Q_OS_HURD
123#elif defined(__QNXNTO__)
124# define Q_OS_QNX
125#elif defined(__INTEGRITY)
126# define Q_OS_INTEGRITY
127#elif defined(__rtems__)
128# define Q_OS_RTEMS
129#elif defined(__vxworks)
130# define Q_OS_VXWORKS
131#elif defined(__HAIKU__)
132# define Q_OS_HAIKU
133#elif defined(__MAKEDEPEND__)
134#else
135# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
136#endif
137
138#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
139# define Q_OS_WINDOWS
140# define Q_OS_WIN
141// On Windows, pointers to dllimport'ed variables are not constant expressions,
142// so to keep to certain initializations (like QMetaObject) constexpr, we need
143// to use functions instead.
144# define QT_NO_DATA_RELOCATION
145#endif
146
147#if defined(Q_OS_WIN)
148# undef Q_OS_UNIX
149#elif !defined(Q_OS_UNIX)
150# define Q_OS_UNIX
151#endif
152
153// Compatibility synonyms
154#ifdef Q_OS_DARWIN
155# pragma clang diagnostic push
156# pragma clang diagnostic ignored "-Wunknown-pragmas"
157# define Q_OS_MAC // FIXME: Deprecate
158# ifdef __LP64__
159# define Q_OS_DARWIN64
160# pragma clang deprecated(Q_OS_DARWIN64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
161# define Q_OS_MAC64
162# pragma clang deprecated(Q_OS_MAC64, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
163# else
164# define Q_OS_DARWIN32
165# pragma clang deprecated(Q_OS_DARWIN32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
166# define Q_OS_MAC32
167# pragma clang deprecated(Q_OS_MAC32, "use Q_OS_DARWIN and QT_POINTER_SIZE/Q_PROCESSOR_* instead")
168# endif
169# ifdef Q_OS_MACOS
170# define Q_OS_MACX
171# pragma clang deprecated(Q_OS_MACX, "use Q_OS_MACOS instead")
172# define Q_OS_OSX
173# pragma clang deprecated(Q_OS_OSX, "use Q_OS_MACOS instead")
174# endif
175# pragma clang diagnostic pop
176#endif
177
178#ifdef Q_OS_DARWIN
179# include <Availability.h>
180# include <AvailabilityMacros.h>
181
182# define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos)
183 ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= macos) ||
184 (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) ||
185 (defined(__TV_OS_VERSION_MAX_ALLOWED) && tvos != __TVOS_NA && __TV_OS_VERSION_MAX_ALLOWED >= tvos) ||
186 (defined(__WATCH_OS_VERSION_MAX_ALLOWED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MAX_ALLOWED >= watchos))
187
188# define QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, tvos, watchos)
189 ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < macos) ||
190 (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) ||
191 (defined(__TV_OS_VERSION_MIN_REQUIRED) && tvos != __TVOS_NA && __TV_OS_VERSION_MIN_REQUIRED < tvos) ||
192 (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MIN_REQUIRED < watchos))
193
194# define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios)
195 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, __TVOS_NA, __WATCHOS_NA)
196# define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos)
197 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
198# define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios)
199 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
200# define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos)
201 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
202# define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos)
203 QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
204
205# define QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(macos, ios)
206 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, __TVOS_NA, __WATCHOS_NA)
207# define QT_MACOS_DEPLOYMENT_TARGET_BELOW(macos)
208 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
209# define QT_IOS_DEPLOYMENT_TARGET_BELOW(ios)
210 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
211# define QT_TVOS_DEPLOYMENT_TARGET_BELOW(tvos)
212 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
213# define QT_WATCHOS_DEPLOYMENT_TARGET_BELOW(watchos)
214 QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
215
216#else // !Q_OS_DARWIN
217
218#define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) (0)
219#define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) (0)
220#define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) (0)
221#define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) (0)
222#define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) (0)
223#define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) (0)
224
225#endif // Q_OS_DARWIN
226
227#ifdef __LSB_VERSION__
228# if __LSB_VERSION__ < 40
229# error "This version of the Linux Standard Base is unsupported"
230# endif
231#ifndef QT_LINUXBASE
232# define QT_LINUXBASE
233#endif
234#endif
235
236#if defined (__ELF__)
237# define Q_OF_ELF
238#endif
239#if defined (__MACH__) && defined (__APPLE__)
240# define Q_OF_MACH_O
241#endif
242
243#if defined(__SIZEOF_INT128__)
244// Compiler used in VxWorks SDK declares __SIZEOF_INT128__ but VxWorks doesn't support this type,
245// so we can't rely solely on compiler here.
246// MSVC STL used by MSVC and clang-cl does not support int128
247#if !defined(Q_OS_VXWORKS) && !defined(_MSC_VER)
248# define QT_COMPILER_SUPPORTS_INT128 __SIZEOF_INT128__
249#endif
250#endif // defined(__SIZEOF_INT128__)
251
252#endif // QSYSTEMDETECTION_H