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