1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Copyright (C) 2016 Intel Corporation.
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the QtCore module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef QGLOBAL_H
42# include <QtCore/qglobal.h>
43#endif
44
45#ifndef QCOMPILERDETECTION_H
46#define QCOMPILERDETECTION_H
47
48/*
49 The compiler, must be one of: (Q_CC_x)
50
51 SYM - Digital Mars C/C++ (used to be Symantec C++)
52 MSVC - Microsoft Visual C/C++, Intel C++ for Windows
53 BOR - Borland/Turbo C++
54 WAT - Watcom C++
55 GNU - GNU C++
56 COMEAU - Comeau C++
57 EDG - Edison Design Group C++
58 OC - CenterLine C++
59 SUN - Forte Developer, or Sun Studio C++
60 MIPS - MIPSpro C++
61 DEC - DEC C++
62 HPACC - HP aC++
63 USLC - SCO OUDK and UDK
64 CDS - Reliant C++
65 KAI - KAI C++
66 INTEL - Intel C++ for Linux, Intel C++ for Windows
67 HIGHC - MetaWare High C/C++
68 PGI - Portland Group C++
69 GHS - Green Hills Optimizing C++ Compilers
70 RVCT - ARM Realview Compiler Suite
71 CLANG - C++ front-end for the LLVM compiler
72
73
74 Should be sorted most to least authoritative.
75*/
76
77/* Symantec C++ is now Digital Mars */
78#if defined(__DMC__) || defined(__SC__)
79# define Q_CC_SYM
80/* "explicit" semantics implemented in 8.1e but keyword recognized since 7.5 */
81# if defined(__SC__) && __SC__ < 0x750
82# error "Compiler not supported"
83# endif
84
85#elif defined(_MSC_VER)
86# ifdef __clang__
87# define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__)
88# endif
89# define Q_CC_MSVC (_MSC_VER)
90# define Q_CC_MSVC_NET
91# define Q_OUTOFLINE_TEMPLATE inline
92# define Q_COMPILER_MANGLES_RETURN_TYPE
93# define Q_FUNC_INFO __FUNCSIG__
94# define Q_ALIGNOF(type) __alignof(type)
95# define Q_DECL_ALIGN(n) __declspec(align(n))
96# define Q_ASSUME_IMPL(expr) __assume(expr)
97# define Q_UNREACHABLE_IMPL() __assume(0)
98# define Q_NORETURN __declspec(noreturn)
99# define Q_DECL_DEPRECATED __declspec(deprecated)
100# ifndef Q_CC_CLANG
101# define Q_DECL_DEPRECATED_X(text) __declspec(deprecated(text))
102# endif
103# define Q_DECL_EXPORT __declspec(dllexport)
104# define Q_DECL_IMPORT __declspec(dllimport)
105# define QT_MAKE_UNCHECKED_ARRAY_ITERATOR(x) stdext::make_unchecked_array_iterator(x) // Since _MSC_VER >= 1800
106# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) stdext::make_checked_array_iterator(x, size_t(N)) // Since _MSC_VER >= 1500
107/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
108# if defined(__INTEL_COMPILER)
109# define Q_DECL_VARIABLE_DEPRECATED
110# define Q_CC_INTEL __INTEL_COMPILER
111# endif
112
113#elif defined(__BORLANDC__) || defined(__TURBOC__)
114# define Q_CC_BOR
115# define Q_INLINE_TEMPLATE
116# if __BORLANDC__ < 0x502
117# error "Compiler not supported"
118# endif
119
120#elif defined(__WATCOMC__)
121# define Q_CC_WAT
122
123/* ARM Realview Compiler Suite
124 RVCT compiler also defines __EDG__ and __GNUC__ (if --gnu flag is given),
125 so check for it before that */
126#elif defined(__ARMCC__) || defined(__CC_ARM)
127# define Q_CC_RVCT
128/* work-around for missing compiler intrinsics */
129# define __is_empty(X) false
130# define __is_pod(X) false
131# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
132# ifdef Q_OS_LINUX
133# define Q_DECL_EXPORT __attribute__((visibility("default")))
134# define Q_DECL_IMPORT __attribute__((visibility("default")))
135# define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
136# else
137# define Q_DECL_EXPORT __declspec(dllexport)
138# define Q_DECL_IMPORT __declspec(dllimport)
139# endif
140
141#elif defined(__GNUC__)
142# define Q_CC_GNU (__GNUC__ * 100 + __GNUC_MINOR__)
143# if defined(__MINGW32__)
144# define Q_CC_MINGW
145# endif
146# if defined(__INTEL_COMPILER)
147/* Intel C++ also masquerades as GCC */
148# define Q_CC_INTEL (__INTEL_COMPILER)
149# ifdef __clang__
150/* Intel C++ masquerades as Clang masquerading as GCC */
151# define Q_CC_CLANG 305
152# endif
153# define Q_ASSUME_IMPL(expr) __assume(expr)
154# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
155# if __INTEL_COMPILER >= 1300 && !defined(__APPLE__)
156# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
157# endif
158# elif defined(__clang__)
159/* Clang also masquerades as GCC */
160# if defined(__apple_build_version__)
161# /* http://en.wikipedia.org/wiki/Xcode#Toolchain_Versions */
162# if __apple_build_version__ >= 8020041
163# define Q_CC_CLANG 309
164# elif __apple_build_version__ >= 8000038
165# define Q_CC_CLANG 308
166# elif __apple_build_version__ >= 7000053
167# define Q_CC_CLANG 306
168# elif __apple_build_version__ >= 6000051
169# define Q_CC_CLANG 305
170# elif __apple_build_version__ >= 5030038
171# define Q_CC_CLANG 304
172# elif __apple_build_version__ >= 5000275
173# define Q_CC_CLANG 303
174# elif __apple_build_version__ >= 4250024
175# define Q_CC_CLANG 302
176# elif __apple_build_version__ >= 3180045
177# define Q_CC_CLANG 301
178# elif __apple_build_version__ >= 2111001
179# define Q_CC_CLANG 300
180# else
181# error "Unknown Apple Clang version"
182# endif
183# else
184# define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__)
185# endif
186# if __has_builtin(__builtin_assume)
187# define Q_ASSUME_IMPL(expr) __builtin_assume(expr)
188# else
189# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
190# endif
191# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
192# if !defined(__has_extension)
193# /* Compatibility with older Clang versions */
194# define __has_extension __has_feature
195# endif
196# if defined(__APPLE__)
197 /* Apple/clang specific features */
198# define Q_DECL_CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
199# ifdef __OBJC__
200# define Q_DECL_NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
201# endif
202# endif
203# ifdef __EMSCRIPTEN__
204# define Q_CC_EMSCRIPTEN
205# endif
206# else
207/* Plain GCC */
208# if Q_CC_GNU >= 405
209# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
210# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
211# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
212# endif
213# endif
214
215# ifdef Q_OS_WIN
216# define Q_DECL_EXPORT __declspec(dllexport)
217# define Q_DECL_IMPORT __declspec(dllimport)
218# elif defined(QT_VISIBILITY_AVAILABLE)
219# define Q_DECL_EXPORT __attribute__((visibility("default")))
220# define Q_DECL_IMPORT __attribute__((visibility("default")))
221# define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
222# endif
223
224# define Q_FUNC_INFO __PRETTY_FUNCTION__
225# define Q_ALIGNOF(type) __alignof__(type)
226# define Q_TYPEOF(expr) __typeof__(expr)
227# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
228# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
229# define Q_DECL_UNUSED __attribute__((__unused__))
230# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
231# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
232# define Q_NORETURN __attribute__((__noreturn__))
233# define Q_REQUIRED_RESULT __attribute__ ((__warn_unused_result__))
234# define Q_DECL_PURE_FUNCTION __attribute__((pure))
235# define Q_DECL_CONST_FUNCTION __attribute__((const))
236# define Q_DECL_COLD_FUNCTION __attribute__((cold))
237# if !defined(QT_MOC_CPP)
238# define Q_PACKED __attribute__ ((__packed__))
239# ifndef __ARM_EABI__
240# define QT_NO_ARM_EABI
241# endif
242# endif
243# if Q_CC_GNU >= 403 && !defined(Q_CC_CLANG)
244# define Q_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
245# endif
246
247/* IBM compiler versions are a bit messy. There are actually two products:
248 the C product, and the C++ product. The C++ compiler is always packaged
249 with the latest version of the C compiler. Version numbers do not always
250 match. This little table (I'm not sure it's accurate) should be helpful:
251
252 C++ product C product
253
254 C Set 3.1 C Compiler 3.0
255 ... ...
256 C++ Compiler 3.6.6 C Compiler 4.3
257 ... ...
258 Visual Age C++ 4.0 ...
259 ... ...
260 Visual Age C++ 5.0 C Compiler 5.0
261 ... ...
262 Visual Age C++ 6.0 C Compiler 6.0
263
264 Now:
265 __xlC__ is the version of the C compiler in hexadecimal notation
266 is only an approximation of the C++ compiler version
267 __IBMCPP__ is the version of the C++ compiler in decimal notation
268 but it is not defined on older compilers like C Set 3.1 */
269#elif defined(__xlC__)
270# define Q_CC_XLC
271# define Q_FULL_TEMPLATE_INSTANTIATION
272# if __xlC__ < 0x400
273# error "Compiler not supported"
274# elif __xlC__ >= 0x0600
275# define Q_ALIGNOF(type) __alignof__(type)
276# define Q_TYPEOF(expr) __typeof__(expr)
277# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
278# define Q_PACKED __attribute__((__packed__))
279# endif
280
281/* Older versions of DEC C++ do not define __EDG__ or __EDG - observed
282 on DEC C++ V5.5-004. New versions do define __EDG__ - observed on
283 Compaq C++ V6.3-002.
284 This compiler is different enough from other EDG compilers to handle
285 it separately anyway. */
286#elif defined(__DECCXX) || defined(__DECC)
287# define Q_CC_DEC
288/* Compaq C++ V6 compilers are EDG-based but I'm not sure about older
289 DEC C++ V5 compilers. */
290# if defined(__EDG__)
291# define Q_CC_EDG
292# endif
293/* Compaq has disabled EDG's _BOOL macro and uses _BOOL_EXISTS instead
294 - observed on Compaq C++ V6.3-002.
295 In any case versions prior to Compaq C++ V6.0-005 do not have bool. */
296# if !defined(_BOOL_EXISTS)
297# error "Compiler not supported"
298# endif
299/* Spurious (?) error messages observed on Compaq C++ V6.5-014. */
300/* Apply to all versions prior to Compaq C++ V6.0-000 - observed on
301 DEC C++ V5.5-004. */
302# if __DECCXX_VER < 60060000
303# define Q_BROKEN_TEMPLATE_SPECIALIZATION
304# endif
305/* avoid undefined symbol problems with out-of-line template members */
306# define Q_OUTOFLINE_TEMPLATE inline
307
308/* The Portland Group C++ compiler is based on EDG and does define __EDG__
309 but the C compiler does not */
310#elif defined(__PGI)
311# define Q_CC_PGI
312# if defined(__EDG__)
313# define Q_CC_EDG
314# endif
315
316/* Compilers with EDG front end are similar. To detect them we test:
317 __EDG documented by SGI, observed on MIPSpro 7.3.1.1 and KAI C++ 4.0b
318 __EDG__ documented in EDG online docs, observed on Compaq C++ V6.3-002
319 and PGI C++ 5.2-4 */
320#elif !defined(Q_OS_HPUX) && (defined(__EDG) || defined(__EDG__))
321# define Q_CC_EDG
322/* From the EDG documentation (does not seem to apply to Compaq C++ or GHS C):
323 _BOOL
324 Defined in C++ mode when bool is a keyword. The name of this
325 predefined macro is specified by a configuration flag. _BOOL
326 is the default.
327 __BOOL_DEFINED
328 Defined in Microsoft C++ mode when bool is a keyword. */
329# if !defined(_BOOL) && !defined(__BOOL_DEFINED) && !defined(__ghs)
330# error "Compiler not supported"
331# endif
332
333/* The Comeau compiler is based on EDG and does define __EDG__ */
334# if defined(__COMO__)
335# define Q_CC_COMEAU
336
337/* The `using' keyword was introduced to avoid KAI C++ warnings
338 but it's now causing KAI C++ errors instead. The standard is
339 unclear about the use of this keyword, and in practice every
340 compiler is using its own set of rules. Forget it. */
341# elif defined(__KCC)
342# define Q_CC_KAI
343
344/* Using the `using' keyword avoids Intel C++ for Linux warnings */
345# elif defined(__INTEL_COMPILER)
346# define Q_CC_INTEL (__INTEL_COMPILER)
347
348/* Uses CFront, make sure to read the manual how to tweak templates. */
349# elif defined(__ghs)
350# define Q_CC_GHS
351# define Q_DECL_DEPRECATED __attribute__ ((__deprecated__))
352# define Q_PACKED __attribute__ ((__packed__))
353# define Q_FUNC_INFO __PRETTY_FUNCTION__
354# define Q_TYPEOF(expr) __typeof__(expr)
355# define Q_ALIGNOF(type) __alignof__(type)
356# define Q_UNREACHABLE_IMPL()
357# if defined(__cplusplus)
358# define Q_COMPILER_AUTO_TYPE
359# define Q_COMPILER_STATIC_ASSERT
360# define Q_COMPILER_RANGE_FOR
361# if __GHS_VERSION_NUMBER >= 201505
362# define Q_COMPILER_ALIGNAS
363# define Q_COMPILER_ALIGNOF
364# define Q_COMPILER_ATOMICS
365# define Q_COMPILER_ATTRIBUTES
366# define Q_COMPILER_AUTO_FUNCTION
367# define Q_COMPILER_CLASS_ENUM
368# define Q_COMPILER_CONSTEXPR
369# define Q_COMPILER_DECLTYPE
370# define Q_COMPILER_DEFAULT_MEMBERS
371# define Q_COMPILER_DELETE_MEMBERS
372# define Q_COMPILER_DELEGATING_CONSTRUCTORS
373# define Q_COMPILER_EXPLICIT_CONVERSIONS
374# define Q_COMPILER_EXPLICIT_OVERRIDES
375# define Q_COMPILER_EXTERN_TEMPLATES
376# define Q_COMPILER_INHERITING_CONSTRUCTORS
377# define Q_COMPILER_INITIALIZER_LISTS
378# define Q_COMPILER_LAMBDA
379# define Q_COMPILER_NONSTATIC_MEMBER_INIT
380# define Q_COMPILER_NOEXCEPT
381# define Q_COMPILER_NULLPTR
382# define Q_COMPILER_RANGE_FOR
383# define Q_COMPILER_RAW_STRINGS
384# define Q_COMPILER_REF_QUALIFIERS
385# define Q_COMPILER_RVALUE_REFS
386# define Q_COMPILER_STATIC_ASSERT
387# define Q_COMPILER_TEMPLATE_ALIAS
388# define Q_COMPILER_THREAD_LOCAL
389# define Q_COMPILER_THREADSAFE_STATICS
390# define Q_COMPILER_UDL
391# define Q_COMPILER_UNICODE_STRINGS
392# define Q_COMPILER_UNIFORM_INIT
393# define Q_COMPILER_UNRESTRICTED_UNIONS
394# define Q_COMPILER_VARIADIC_MACROS
395# define Q_COMPILER_VARIADIC_TEMPLATES
396# endif
397# endif //__cplusplus
398
399# elif defined(__DCC__)
400# define Q_CC_DIAB
401# if !defined(__bool)
402# error "Compiler not supported"
403# endif
404
405/* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */
406# elif defined(__USLC__) && defined(__SCO_VERSION__)
407# define Q_CC_USLC
408/* The latest UDK 7.1.1b does not need this, but previous versions do */
409# if !defined(__SCO_VERSION__) || (__SCO_VERSION__ < 302200010)
410# define Q_OUTOFLINE_TEMPLATE inline
411# endif
412
413/* Never tested! */
414# elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER)
415# define Q_CC_OC
416
417/* CDS++ defines __EDG__ although this is not documented in the Reliant
418 documentation. It also follows conventions like _BOOL and this documented */
419# elif defined(sinix)
420# define Q_CC_CDS
421
422/* The MIPSpro compiler defines __EDG */
423# elif defined(__sgi)
424# define Q_CC_MIPS
425# define Q_NO_TEMPLATE_FRIENDS
426# if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 740)
427# define Q_OUTOFLINE_TEMPLATE inline
428# pragma set woff 3624,3625,3649 /* turn off some harmless warnings */
429# endif
430# endif
431
432/* VxWorks' DIAB toolchain has an additional EDG type C++ compiler
433 (see __DCC__ above). This one is for C mode files (__EDG is not defined) */
434#elif defined(_DIAB_TOOL)
435# define Q_CC_DIAB
436# define Q_FUNC_INFO __PRETTY_FUNCTION__
437
438/* Never tested! */
439#elif defined(__HIGHC__)
440# define Q_CC_HIGHC
441
442#elif defined(__SUNPRO_CC) || defined(__SUNPRO_C)
443# define Q_CC_SUN
444# define Q_COMPILER_MANGLES_RETURN_TYPE
445/* 5.0 compiler or better
446 'bool' is enabled by default but can be disabled using -features=nobool
447 in which case _BOOL is not defined
448 this is the default in 4.2 compatibility mode triggered by -compat=4 */
449# if __SUNPRO_CC >= 0x500
450# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
451 /* see http://developers.sun.com/sunstudio/support/Ccompare.html */
452# if __SUNPRO_CC >= 0x590
453# define Q_ALIGNOF(type) __alignof__(type)
454# define Q_TYPEOF(expr) __typeof__(expr)
455# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
456# endif
457# if __SUNPRO_CC >= 0x550
458# define Q_DECL_EXPORT __global
459# endif
460# if __SUNPRO_CC < 0x5a0
461# define Q_NO_TEMPLATE_FRIENDS
462# endif
463# if !defined(_BOOL)
464# error "Compiler not supported"
465# endif
466/* 4.2 compiler or older */
467# else
468# error "Compiler not supported"
469# endif
470
471/* CDS++ does not seem to define __EDG__ or __EDG according to Reliant
472 documentation but nevertheless uses EDG conventions like _BOOL */
473#elif defined(sinix)
474# define Q_CC_EDG
475# define Q_CC_CDS
476# if !defined(_BOOL)
477# error "Compiler not supported"
478# endif
479# define Q_BROKEN_TEMPLATE_SPECIALIZATION
480
481#elif defined(Q_OS_HPUX)
482/* __HP_aCC was not defined in first aCC releases */
483# if defined(__HP_aCC) || __cplusplus >= 199707L
484# define Q_NO_TEMPLATE_FRIENDS
485# define Q_CC_HPACC
486# define Q_FUNC_INFO __PRETTY_FUNCTION__
487# if __HP_aCC-0 < 060000
488# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
489# define Q_DECL_EXPORT __declspec(dllexport)
490# define Q_DECL_IMPORT __declspec(dllimport)
491# endif
492# if __HP_aCC-0 >= 061200
493# define Q_DECL_ALIGN(n) __attribute__((aligned(n)))
494# endif
495# if __HP_aCC-0 >= 062000
496# define Q_DECL_EXPORT __attribute__((visibility("default")))
497# define Q_DECL_HIDDEN __attribute__((visibility("hidden")))
498# define Q_DECL_IMPORT Q_DECL_EXPORT
499# endif
500# else
501# error "Compiler not supported"
502# endif
503
504#else
505# error "Qt has not been tested with this compiler - see http://www.qt-project.org/"
506#endif
507
508/*
509 * C++11 support
510 *
511 * Paper Macro SD-6 macro
512 * N2341 Q_COMPILER_ALIGNAS
513 * N2341 Q_COMPILER_ALIGNOF
514 * N2427 Q_COMPILER_ATOMICS
515 * N2761 Q_COMPILER_ATTRIBUTES __cpp_attributes = 200809
516 * N2541 Q_COMPILER_AUTO_FUNCTION
517 * N1984 N2546 Q_COMPILER_AUTO_TYPE
518 * N2437 Q_COMPILER_CLASS_ENUM
519 * N2235 Q_COMPILER_CONSTEXPR __cpp_constexpr = 200704
520 * N2343 N3276 Q_COMPILER_DECLTYPE __cpp_decltype = 200707
521 * N2346 Q_COMPILER_DEFAULT_MEMBERS
522 * N2346 Q_COMPILER_DELETE_MEMBERS
523 * N1986 Q_COMPILER_DELEGATING_CONSTRUCTORS
524 * N2437 Q_COMPILER_EXPLICIT_CONVERSIONS
525 * N3206 N3272 Q_COMPILER_EXPLICIT_OVERRIDES
526 * N1987 Q_COMPILER_EXTERN_TEMPLATES
527 * N2540 Q_COMPILER_INHERITING_CONSTRUCTORS
528 * N2672 Q_COMPILER_INITIALIZER_LISTS
529 * N2658 N2927 Q_COMPILER_LAMBDA __cpp_lambdas = 200907
530 * N2756 Q_COMPILER_NONSTATIC_MEMBER_INIT
531 * N2855 N3050 Q_COMPILER_NOEXCEPT
532 * N2431 Q_COMPILER_NULLPTR
533 * N2930 Q_COMPILER_RANGE_FOR
534 * N2442 Q_COMPILER_RAW_STRINGS __cpp_raw_strings = 200710
535 * N2439 Q_COMPILER_REF_QUALIFIERS
536 * N2118 N2844 N3053 Q_COMPILER_RVALUE_REFS __cpp_rvalue_references = 200610
537 * N1720 Q_COMPILER_STATIC_ASSERT __cpp_static_assert = 200410
538 * N2258 Q_COMPILER_TEMPLATE_ALIAS
539 * N2659 Q_COMPILER_THREAD_LOCAL
540 * N2660 Q_COMPILER_THREADSAFE_STATICS
541 * N2765 Q_COMPILER_UDL __cpp_user_defined_literals = 200809
542 * N2442 Q_COMPILER_UNICODE_STRINGS __cpp_unicode_literals = 200710
543 * N2640 Q_COMPILER_UNIFORM_INIT
544 * N2544 Q_COMPILER_UNRESTRICTED_UNIONS
545 * N1653 Q_COMPILER_VARIADIC_MACROS
546 * N2242 N2555 Q_COMPILER_VARIADIC_TEMPLATES __cpp_variadic_templates = 200704
547 *
548 * For any future version of the C++ standard, we use only the SD-6 macro.
549 * For full listing, see
550 * http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
551 *
552 * C++ extensions:
553 * Q_COMPILER_RESTRICTED_VLA variable-length arrays, prior to __cpp_runtime_arrays
554 */
555
556#ifdef __cplusplus
557# if __cplusplus < 201103L && !defined(Q_CC_MSVC)
558# error Qt requires a C++11 compiler and yours does not seem to be that.
559# endif
560#endif
561
562#if defined(Q_CC_INTEL) && !defined(Q_CC_MSVC)
563# define Q_COMPILER_RESTRICTED_VLA
564# define Q_COMPILER_VARIADIC_MACROS // C++11 feature supported as an extension in other modes, too
565# define Q_COMPILER_THREADSAFE_STATICS
566# if __INTEL_COMPILER < 1200
567# define Q_NO_TEMPLATE_FRIENDS
568# endif
569# if __INTEL_COMPILER >= 1310 && !defined(_WIN32)
570// ICC supports C++14 binary literals in C, C++98, and C++11 modes
571// at least since 13.1, but I can't test further back
572# define Q_COMPILER_BINARY_LITERALS
573# endif
574# if __cplusplus >= 201103L || defined(__INTEL_CXX11_MODE__)
575# if __INTEL_COMPILER >= 1200
576# define Q_COMPILER_AUTO_TYPE
577# define Q_COMPILER_CLASS_ENUM
578# define Q_COMPILER_DECLTYPE
579# define Q_COMPILER_DEFAULT_MEMBERS
580# define Q_COMPILER_DELETE_MEMBERS
581# define Q_COMPILER_EXTERN_TEMPLATES
582# define Q_COMPILER_LAMBDA
583# define Q_COMPILER_RVALUE_REFS
584# define Q_COMPILER_STATIC_ASSERT
585# define Q_COMPILER_VARIADIC_MACROS
586# endif
587# if __INTEL_COMPILER >= 1210
588# define Q_COMPILER_ATTRIBUTES
589# define Q_COMPILER_AUTO_FUNCTION
590# define Q_COMPILER_NULLPTR
591# define Q_COMPILER_TEMPLATE_ALIAS
592# ifndef _CHAR16T // MSVC headers
593# define Q_COMPILER_UNICODE_STRINGS
594# endif
595# define Q_COMPILER_VARIADIC_TEMPLATES
596# endif
597# if __INTEL_COMPILER >= 1300
598# define Q_COMPILER_ATOMICS
599// constexpr support is only partial
600//# define Q_COMPILER_CONSTEXPR
601# define Q_COMPILER_INITIALIZER_LISTS
602# define Q_COMPILER_UNIFORM_INIT
603# define Q_COMPILER_NOEXCEPT
604# endif
605# if __INTEL_COMPILER >= 1400
606// causes issues with QArrayData and QtPrivate::RefCount - Intel issue ID 6000056211, bug DPD200534796
607//# define Q_COMPILER_CONSTEXPR
608# define Q_COMPILER_DELEGATING_CONSTRUCTORS
609# define Q_COMPILER_EXPLICIT_CONVERSIONS
610# define Q_COMPILER_EXPLICIT_OVERRIDES
611# define Q_COMPILER_NONSTATIC_MEMBER_INIT
612# define Q_COMPILER_RANGE_FOR
613# define Q_COMPILER_RAW_STRINGS
614# define Q_COMPILER_REF_QUALIFIERS
615# define Q_COMPILER_UNICODE_STRINGS
616# define Q_COMPILER_UNRESTRICTED_UNIONS
617# endif
618# if __INTEL_COMPILER >= 1500
619# if __INTEL_COMPILER * 100 + __INTEL_COMPILER_UPDATE >= 150001
620// the bug mentioned above is fixed in 15.0.1
621# define Q_COMPILER_CONSTEXPR
622# endif
623# define Q_COMPILER_ALIGNAS
624# define Q_COMPILER_ALIGNOF
625# define Q_COMPILER_INHERITING_CONSTRUCTORS
626# define Q_COMPILER_THREAD_LOCAL
627# define Q_COMPILER_UDL
628# endif
629# elif defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
630// C11 features supported. Only tested with ICC 17 and up.
631# define Q_COMPILER_STATIC_ASSERT
632# if __has_include(<threads.h>)
633# define Q_COMPILER_THREAD_LOCAL
634# endif
635# endif
636#endif
637
638#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !defined(Q_CC_MSVC)
639/* General C++ features */
640# define Q_COMPILER_RESTRICTED_VLA
641# define Q_COMPILER_THREADSAFE_STATICS
642# if __has_feature(attribute_deprecated_with_message)
643# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
644# endif
645
646// Clang supports binary literals in C, C++98 and C++11 modes
647// It's been supported "since the dawn of time itself" (cf. commit 179883)
648# if __has_extension(cxx_binary_literals)
649# define Q_COMPILER_BINARY_LITERALS
650# endif
651
652// Variadic macros are supported for gnu++98, c++11, c99 ... since 2.9
653# if Q_CC_CLANG >= 209
654# if !defined(__STRICT_ANSI__) || defined(__GXX_EXPERIMENTAL_CXX0X__) \
655 || (defined(__cplusplus) && (__cplusplus >= 201103L)) \
656 || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
657# define Q_COMPILER_VARIADIC_MACROS
658# endif
659# endif
660
661/* C++11 features, see http://clang.llvm.org/cxx_status.html */
662# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
663 /* Detect C++ features using __has_feature(), see http://clang.llvm.org/docs/LanguageExtensions.html#cxx11 */
664# if __has_feature(cxx_alignas)
665# define Q_COMPILER_ALIGNAS
666# define Q_COMPILER_ALIGNOF
667# endif
668# if __has_feature(cxx_atomic) && __has_include(<atomic>)
669# define Q_COMPILER_ATOMICS
670# endif
671# if __has_feature(cxx_attributes)
672# define Q_COMPILER_ATTRIBUTES
673# endif
674# if __has_feature(cxx_auto_type)
675# define Q_COMPILER_AUTO_FUNCTION
676# define Q_COMPILER_AUTO_TYPE
677# endif
678# if __has_feature(cxx_strong_enums)
679# define Q_COMPILER_CLASS_ENUM
680# endif
681# if __has_feature(cxx_constexpr) && Q_CC_CLANG > 302 /* CLANG 3.2 has bad/partial support */
682# define Q_COMPILER_CONSTEXPR
683# endif
684# if __has_feature(cxx_decltype) /* && __has_feature(cxx_decltype_incomplete_return_types) */
685# define Q_COMPILER_DECLTYPE
686# endif
687# if __has_feature(cxx_defaulted_functions)
688# define Q_COMPILER_DEFAULT_MEMBERS
689# endif
690# if __has_feature(cxx_deleted_functions)
691# define Q_COMPILER_DELETE_MEMBERS
692# endif
693# if __has_feature(cxx_delegating_constructors)
694# define Q_COMPILER_DELEGATING_CONSTRUCTORS
695# endif
696# if __has_feature(cxx_explicit_conversions)
697# define Q_COMPILER_EXPLICIT_CONVERSIONS
698# endif
699# if __has_feature(cxx_override_control)
700# define Q_COMPILER_EXPLICIT_OVERRIDES
701# endif
702# if __has_feature(cxx_inheriting_constructors)
703# define Q_COMPILER_INHERITING_CONSTRUCTORS
704# endif
705# if __has_feature(cxx_generalized_initializers)
706# define Q_COMPILER_INITIALIZER_LISTS
707# define Q_COMPILER_UNIFORM_INIT /* both covered by this feature macro, according to docs */
708# endif
709# if __has_feature(cxx_lambdas)
710# define Q_COMPILER_LAMBDA
711# endif
712# if __has_feature(cxx_noexcept)
713# define Q_COMPILER_NOEXCEPT
714# endif
715# if __has_feature(cxx_nonstatic_member_init)
716# define Q_COMPILER_NONSTATIC_MEMBER_INIT
717# endif
718# if __has_feature(cxx_nullptr)
719# define Q_COMPILER_NULLPTR
720# endif
721# if __has_feature(cxx_range_for)
722# define Q_COMPILER_RANGE_FOR
723# endif
724# if __has_feature(cxx_raw_string_literals)
725# define Q_COMPILER_RAW_STRINGS
726# endif
727# if __has_feature(cxx_reference_qualified_functions)
728# define Q_COMPILER_REF_QUALIFIERS
729# endif
730# if __has_feature(cxx_rvalue_references)
731# define Q_COMPILER_RVALUE_REFS
732# endif
733# if __has_feature(cxx_static_assert)
734# define Q_COMPILER_STATIC_ASSERT
735# endif
736# if __has_feature(cxx_alias_templates)
737# define Q_COMPILER_TEMPLATE_ALIAS
738# endif
739# if __has_feature(cxx_thread_local)
740# if !defined(__FreeBSD__) /* FreeBSD clang fails on __cxa_thread_atexit */
741# define Q_COMPILER_THREAD_LOCAL
742# endif
743# endif
744# if __has_feature(cxx_user_literals)
745# define Q_COMPILER_UDL
746# endif
747# if __has_feature(cxx_unicode_literals)
748# define Q_COMPILER_UNICODE_STRINGS
749# endif
750# if __has_feature(cxx_unrestricted_unions)
751# define Q_COMPILER_UNRESTRICTED_UNIONS
752# endif
753# if __has_feature(cxx_variadic_templates)
754# define Q_COMPILER_VARIADIC_TEMPLATES
755# endif
756 /* Features that have no __has_feature() check */
757# if Q_CC_CLANG >= 209 /* since clang 2.9 */
758# define Q_COMPILER_EXTERN_TEMPLATES
759# endif
760# endif
761
762/* C++1y features, deprecated macros. Do not update this list. */
763# if __cplusplus > 201103L
764//# if __has_feature(cxx_binary_literals)
765//# define Q_COMPILER_BINARY_LITERALS // see above
766//# endif
767# if __has_feature(cxx_generic_lambda)
768# define Q_COMPILER_GENERIC_LAMBDA
769# endif
770# if __has_feature(cxx_init_capture)
771# define Q_COMPILER_LAMBDA_CAPTURES
772# endif
773# if __has_feature(cxx_relaxed_constexpr)
774# define Q_COMPILER_RELAXED_CONSTEXPR_FUNCTIONS
775# endif
776# if __has_feature(cxx_decltype_auto) && __has_feature(cxx_return_type_deduction)
777# define Q_COMPILER_RETURN_TYPE_DEDUCTION
778# endif
779# if __has_feature(cxx_variable_templates)
780# define Q_COMPILER_VARIABLE_TEMPLATES
781# endif
782# if __has_feature(cxx_runtime_array)
783# define Q_COMPILER_VLA
784# endif
785# endif
786
787# if defined(__STDC_VERSION__)
788# if __has_feature(c_static_assert)
789# define Q_COMPILER_STATIC_ASSERT
790# endif
791# if __has_feature(c_thread_local) && __has_include(<threads.h>)
792# if !defined(__FreeBSD__) /* FreeBSD clang fails on __cxa_thread_atexit */
793# define Q_COMPILER_THREAD_LOCAL
794# endif
795# endif
796# endif
797
798# if defined(__has_warning)
799# if __has_warning("-Wunused-private-field")
800# define Q_DECL_UNUSED_MEMBER Q_DECL_UNUSED
801# endif
802# endif
803
804#endif // Q_CC_CLANG
805
806#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
807# define Q_COMPILER_RESTRICTED_VLA
808# define Q_COMPILER_THREADSAFE_STATICS
809# if Q_CC_GNU >= 403
810// GCC supports binary literals in C, C++98 and C++11 modes
811# define Q_COMPILER_BINARY_LITERALS
812# endif
813# if !defined(__STRICT_ANSI__) || defined(__GXX_EXPERIMENTAL_CXX0X__) \
814 || (defined(__cplusplus) && (__cplusplus >= 201103L)) \
815 || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
816 // Variadic macros are supported for gnu++98, c++11, C99 ... since forever (gcc 2.97)
817# define Q_COMPILER_VARIADIC_MACROS
818# endif
819# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
820# if Q_CC_GNU >= 403
821 /* C++11 features supported in GCC 4.3: */
822# define Q_COMPILER_DECLTYPE
823# define Q_COMPILER_RVALUE_REFS
824# define Q_COMPILER_STATIC_ASSERT
825# endif
826# if Q_CC_GNU >= 404
827 /* C++11 features supported in GCC 4.4: */
828# define Q_COMPILER_AUTO_FUNCTION
829# define Q_COMPILER_AUTO_TYPE
830# define Q_COMPILER_EXTERN_TEMPLATES
831# define Q_COMPILER_UNIFORM_INIT
832# define Q_COMPILER_UNICODE_STRINGS
833# define Q_COMPILER_VARIADIC_TEMPLATES
834# endif
835# if Q_CC_GNU >= 405
836 /* C++11 features supported in GCC 4.5: */
837# define Q_COMPILER_EXPLICIT_CONVERSIONS
838 /* GCC 4.4 implements initializer_list but does not define typedefs required
839 * by the standard. */
840# define Q_COMPILER_INITIALIZER_LISTS
841# define Q_COMPILER_LAMBDA
842# define Q_COMPILER_RAW_STRINGS
843# define Q_COMPILER_CLASS_ENUM
844# endif
845# if Q_CC_GNU >= 406
846 /* Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete
847 * functions are supported only if they are public. Starting from 4.6, GCC handles
848 * final version - the access modifier is not relevant. */
849# define Q_COMPILER_DEFAULT_MEMBERS
850# define Q_COMPILER_DELETE_MEMBERS
851 /* C++11 features supported in GCC 4.6: */
852# define Q_COMPILER_CONSTEXPR
853# define Q_COMPILER_NULLPTR
854# define Q_COMPILER_UNRESTRICTED_UNIONS
855# define Q_COMPILER_RANGE_FOR
856# endif
857# if Q_CC_GNU >= 407
858 /* GCC 4.4 implemented <atomic> and std::atomic using its old intrinsics.
859 * However, the implementation is incomplete for most platforms until GCC 4.7:
860 * instead, std::atomic would use an external lock. Since we need an std::atomic
861 * that is behavior-compatible with QBasicAtomic, we only enable it here */
862# define Q_COMPILER_ATOMICS
863 /* GCC 4.6.x has problems dealing with noexcept expressions,
864 * so turn the feature on for 4.7 and above, only */
865# define Q_COMPILER_NOEXCEPT
866 /* C++11 features supported in GCC 4.7: */
867# define Q_COMPILER_NONSTATIC_MEMBER_INIT
868# define Q_COMPILER_DELEGATING_CONSTRUCTORS
869# define Q_COMPILER_EXPLICIT_OVERRIDES
870# define Q_COMPILER_TEMPLATE_ALIAS
871# define Q_COMPILER_UDL
872# endif
873# if Q_CC_GNU >= 408
874# define Q_COMPILER_ATTRIBUTES
875# define Q_COMPILER_ALIGNAS
876# define Q_COMPILER_ALIGNOF
877# define Q_COMPILER_INHERITING_CONSTRUCTORS
878# define Q_COMPILER_THREAD_LOCAL
879# if Q_CC_GNU > 408 || __GNUC_PATCHLEVEL__ >= 1
880# define Q_COMPILER_REF_QUALIFIERS
881# endif
882# endif
883 /* C++11 features are complete as of GCC 4.8.1 */
884# endif
885# if __cplusplus > 201103L
886# if Q_CC_GNU >= 409
887 /* C++1y features in GCC 4.9 - deprecated, do not update this list */
888//# define Q_COMPILER_BINARY_LITERALS // already supported since GCC 4.3 as an extension
889# define Q_COMPILER_LAMBDA_CAPTURES
890# define Q_COMPILER_RETURN_TYPE_DEDUCTION
891# endif
892# endif
893# if defined(__STDC_VERSION__) && __STDC_VERSION__ > 199901L
894# if Q_CC_GNU >= 407
895 /* C11 features supported in GCC 4.7: */
896# define Q_COMPILER_STATIC_ASSERT
897# endif
898# if Q_CC_GNU >= 409 && defined(__has_include)
899 /* C11 features supported in GCC 4.9: */
900# if __has_include(<threads.h>)
901# define Q_COMPILER_THREAD_LOCAL
902# endif
903# endif
904# endif
905#endif
906
907#if defined(Q_CC_MSVC)
908# if defined(__cplusplus)
909 /* C++11 features supported in VC8 = VC2005: */
910# define Q_COMPILER_VARIADIC_MACROS
911
912 /* 2005 supports the override and final contextual keywords, in
913 the same positions as the C++11 variants, but 'final' is
914 called 'sealed' instead:
915 http://msdn.microsoft.com/en-us/library/0w2w91tf%28v=vs.80%29.aspx
916 The behavior is slightly different in C++/CLI, which requires the
917 "virtual" keyword to be present too, so don't define for that.
918 So don't define Q_COMPILER_EXPLICIT_OVERRIDES (since it's not
919 the same as the C++11 version), but define the Q_DECL_* flags
920 accordingly. */
921 /* C++11 features supported in VC10 = VC2010: */
922# define Q_COMPILER_AUTO_FUNCTION
923# define Q_COMPILER_AUTO_TYPE
924# define Q_COMPILER_DECLTYPE
925# define Q_COMPILER_EXTERN_TEMPLATES
926# define Q_COMPILER_LAMBDA
927# define Q_COMPILER_NULLPTR
928# define Q_COMPILER_RVALUE_REFS
929# define Q_COMPILER_STATIC_ASSERT
930 /* C++11 features supported in VC11 = VC2012: */
931# define Q_COMPILER_EXPLICIT_OVERRIDES /* ...and use std C++11 now */
932# define Q_COMPILER_CLASS_ENUM
933# define Q_COMPILER_ATOMICS
934 /* C++11 features in VC12 = VC2013 */
935# define Q_COMPILER_DELETE_MEMBERS
936# define Q_COMPILER_DELEGATING_CONSTRUCTORS
937# define Q_COMPILER_EXPLICIT_CONVERSIONS
938# define Q_COMPILER_NONSTATIC_MEMBER_INIT
939# define Q_COMPILER_RAW_STRINGS
940# define Q_COMPILER_TEMPLATE_ALIAS
941# define Q_COMPILER_VARIADIC_TEMPLATES
942# define Q_COMPILER_INITIALIZER_LISTS // VC 12 SP 2 RC
943 /* C++11 features in VC14 = VC2015 */
944# define Q_COMPILER_DEFAULT_MEMBERS
945# define Q_COMPILER_ALIGNAS
946# define Q_COMPILER_ALIGNOF
947# define Q_COMPILER_INHERITING_CONSTRUCTORS
948# define Q_COMPILER_NOEXCEPT
949# define Q_COMPILER_RANGE_FOR
950# define Q_COMPILER_REF_QUALIFIERS
951# define Q_COMPILER_THREAD_LOCAL
952# define Q_COMPILER_UDL
953# define Q_COMPILER_UNICODE_STRINGS
954# define Q_COMPILER_UNRESTRICTED_UNIONS
955# if _MSC_FULL_VER >= 190023419
956# define Q_COMPILER_ATTRIBUTES
957// Almost working, see https://connect.microsoft.com/VisualStudio/feedback/details/2011648
958//# define Q_COMPILER_CONSTEXPR
959# define Q_COMPILER_THREADSAFE_STATICS
960# define Q_COMPILER_UNIFORM_INIT
961# endif
962# if _MSC_VER >= 1910
963# define Q_COMPILER_CONSTEXPR
964# endif
965# endif /* __cplusplus */
966#endif /* Q_CC_MSVC */
967
968#ifdef Q_COMPILER_UNICODE_STRINGS
969# define Q_STDLIB_UNICODE_STRINGS
970#endif
971
972#ifdef __cplusplus
973# include <utility>
974# if defined(Q_OS_QNX)
975// By default, QNX 7.0 uses libc++ (from LLVM) and
976// QNX 6.X uses Dinkumware's libcpp. In all versions,
977// it is also possible to use GNU libstdc++.
978
979// For Dinkumware, some features must be disabled
980// (mostly because of library problems).
981// Dinkumware is assumed when __GLIBCXX__ (GNU libstdc++)
982// and _LIBCPP_VERSION (LLVM libc++) are both absent.
983# if !defined(__GLIBCXX__) && !defined(_LIBCPP_VERSION)
984
985// Older versions of libcpp (QNX 650) do not support C++11 features
986// _HAS_* macros are set to 1 by toolchains that actually include
987// Dinkum C++11 libcpp.
988
989# if !defined(_HAS_CPP0X) || !_HAS_CPP0X
990// Disable C++11 features that depend on library support
991# undef Q_COMPILER_INITIALIZER_LISTS
992# undef Q_COMPILER_RVALUE_REFS
993# undef Q_COMPILER_REF_QUALIFIERS
994# undef Q_COMPILER_NOEXCEPT
995// Disable C++11 library features:
996# undef Q_STDLIB_UNICODE_STRINGS
997# endif // !_HAS_CPP0X
998# if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T
999# undef Q_COMPILER_NULLPTR
1000# endif //!_HAS_NULLPTR_T
1001# if !defined(_HAS_CONSTEXPR) || !_HAS_CONSTEXPR
1002// The libcpp is missing constexpr keywords on important functions like std::numeric_limits<>::min()
1003// Disable constexpr support on QNX even if the compiler supports it
1004# undef Q_COMPILER_CONSTEXPR
1005# endif // !_HAS_CONSTEXPR
1006# endif // !__GLIBCXX__ && !_LIBCPP_VERSION
1007# endif // Q_OS_QNX
1008# if (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) && defined(Q_OS_MAC) && defined(__GNUC_LIBSTD__) \
1009 && ((__GNUC_LIBSTD__-0) * 100 + __GNUC_LIBSTD_MINOR__-0 <= 402)
1010// Apple has not updated libstdc++ since 2007, which means it does not have
1011// <initializer_list> or std::move. Let's disable these features
1012# undef Q_COMPILER_INITIALIZER_LISTS
1013# undef Q_COMPILER_RVALUE_REFS
1014# undef Q_COMPILER_REF_QUALIFIERS
1015// Also disable <atomic>, since it's clearly not there
1016# undef Q_COMPILER_ATOMICS
1017# endif
1018# if defined(Q_CC_CLANG) && defined(Q_CC_INTEL) && Q_CC_INTEL >= 1500
1019// ICC 15.x and 16.0 have their own implementation of std::atomic, which is activated when in Clang mode
1020// (probably because libc++'s <atomic> on OS X failed to compile), but they're missing some
1021// critical definitions. (Reported as Intel Issue ID 6000117277)
1022# define __USE_CONSTEXPR 1
1023# define __USE_NOEXCEPT 1
1024# endif
1025# if defined(Q_COMPILER_THREADSAFE_STATICS) && defined(Q_OS_MAC)
1026// Apple's low-level implementation of the C++ support library
1027// (libc++abi.dylib, shared between libstdc++ and libc++) has deadlocks. The
1028// C++11 standard requires the deadlocks to be removed, so this will eventually
1029// be fixed; for now, let's disable this.
1030# undef Q_COMPILER_THREADSAFE_STATICS
1031# endif
1032#endif
1033
1034/*
1035 * SG10's SD-6 feature detection and some useful extensions from Clang and GCC
1036 * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations
1037 * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros
1038 */
1039#ifdef __has_builtin
1040# define QT_HAS_BUILTIN(x) __has_builtin(x)
1041#else
1042# define QT_HAS_BUILTIN(x) 0
1043#endif
1044#ifdef __has_attribute
1045# define QT_HAS_ATTRIBUTE(x) __has_attribute(x)
1046#else
1047# define QT_HAS_ATTRIBUTE(x) 0
1048#endif
1049#ifdef __has_cpp_attribute
1050# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
1051#else
1052# define QT_HAS_CPP_ATTRIBUTE(x) 0
1053#endif
1054#ifdef __has_include
1055# define QT_HAS_INCLUDE(x) __has_include(x)
1056#else
1057# define QT_HAS_INCLUDE(x) 0
1058#endif
1059#ifdef __has_include_next
1060# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x)
1061#else
1062# define QT_HAS_INCLUDE_NEXT(x) 0
1063#endif
1064
1065/*
1066 * C++11 keywords and expressions
1067 */
1068#ifdef Q_COMPILER_NULLPTR
1069# define Q_NULLPTR nullptr
1070#else
1071# define Q_NULLPTR NULL
1072#endif
1073
1074#ifdef Q_COMPILER_DEFAULT_MEMBERS
1075# define Q_DECL_EQ_DEFAULT = default
1076#else
1077# define Q_DECL_EQ_DEFAULT
1078#endif
1079
1080#ifdef Q_COMPILER_DELETE_MEMBERS
1081# define Q_DECL_EQ_DELETE = delete
1082#else
1083# define Q_DECL_EQ_DELETE
1084#endif
1085
1086// Don't break code that is already using Q_COMPILER_DEFAULT_DELETE_MEMBERS
1087#if defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
1088# define Q_COMPILER_DEFAULT_DELETE_MEMBERS
1089#endif
1090
1091#if defined Q_COMPILER_CONSTEXPR
1092# if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
1093# define Q_DECL_CONSTEXPR constexpr
1094# define Q_DECL_RELAXED_CONSTEXPR constexpr
1095# define Q_CONSTEXPR constexpr
1096# define Q_RELAXED_CONSTEXPR constexpr
1097# else
1098# define Q_DECL_CONSTEXPR constexpr
1099# define Q_DECL_RELAXED_CONSTEXPR
1100# define Q_CONSTEXPR constexpr
1101# define Q_RELAXED_CONSTEXPR const
1102# endif
1103#else
1104# define Q_DECL_CONSTEXPR
1105# define Q_DECL_RELAXED_CONSTEXPR
1106# define Q_CONSTEXPR const
1107# define Q_RELAXED_CONSTEXPR const
1108#endif
1109
1110#ifdef Q_COMPILER_EXPLICIT_OVERRIDES
1111# define Q_DECL_OVERRIDE override
1112# define Q_DECL_FINAL final
1113#else
1114# ifndef Q_DECL_OVERRIDE
1115# define Q_DECL_OVERRIDE
1116# endif
1117# ifndef Q_DECL_FINAL
1118# define Q_DECL_FINAL
1119# endif
1120#endif
1121
1122#ifdef Q_COMPILER_NOEXCEPT
1123# define Q_DECL_NOEXCEPT noexcept
1124# define Q_DECL_NOEXCEPT_EXPR(x) noexcept(x)
1125#else
1126# define Q_DECL_NOEXCEPT
1127# define Q_DECL_NOEXCEPT_EXPR(x)
1128#endif
1129#define Q_DECL_NOTHROW Q_DECL_NOEXCEPT
1130
1131#if defined(Q_COMPILER_ALIGNOF)
1132# undef Q_ALIGNOF
1133# define Q_ALIGNOF(x) alignof(x)
1134#endif
1135
1136#if defined(Q_COMPILER_ALIGNAS)
1137# undef Q_DECL_ALIGN
1138# define Q_DECL_ALIGN(n) alignas(n)
1139#endif
1140
1141#if QT_HAS_CPP_ATTRIBUTE(nodiscard) && !defined(Q_CC_CLANG) // P0188R1
1142// Can't use [[nodiscard]] with Clang, see https://bugs.llvm.org/show_bug.cgi?id=33518
1143# undef Q_REQUIRED_RESULT
1144# define Q_REQUIRED_RESULT [[nodiscard]]
1145#endif
1146
1147#if defined(__cpp_enumerator_attributes) && __cpp_enumerator_attributes >= 201411
1148#if defined(Q_CC_MSVC)
1149// Can't mark enum values as __declspec(deprecated) with MSVC, also can't move
1150// everything to [[deprecated]] because MSVC gives a compilation error when marking
1151// friend methods of a class as [[deprecated("text")]], breaking qstring.h
1152# define Q_DECL_ENUMERATOR_DEPRECATED [[deprecated]]
1153# define Q_DECL_ENUMERATOR_DEPRECATED_X(x) [[deprecated(x)]]
1154#else
1155# define Q_DECL_ENUMERATOR_DEPRECATED Q_DECL_DEPRECATED
1156# define Q_DECL_ENUMERATOR_DEPRECATED_X(x) Q_DECL_DEPRECATED_X(x)
1157#endif
1158#endif
1159
1160/*
1161 * Fallback macros to certain compiler features
1162 */
1163
1164#ifndef Q_NORETURN
1165# define Q_NORETURN
1166#endif
1167#ifndef Q_LIKELY
1168# define Q_LIKELY(x) (x)
1169#endif
1170#ifndef Q_UNLIKELY
1171# define Q_UNLIKELY(x) (x)
1172#endif
1173#ifndef Q_ASSUME_IMPL
1174# define Q_ASSUME_IMPL(expr) qt_noop()
1175#endif
1176#ifndef Q_UNREACHABLE_IMPL
1177# define Q_UNREACHABLE_IMPL() qt_noop()
1178#endif
1179#ifndef Q_ALLOC_SIZE
1180# define Q_ALLOC_SIZE(x)
1181#endif
1182#ifndef Q_REQUIRED_RESULT
1183# define Q_REQUIRED_RESULT
1184#endif
1185#ifndef Q_DECL_DEPRECATED
1186# define Q_DECL_DEPRECATED
1187#endif
1188#ifndef Q_DECL_VARIABLE_DEPRECATED
1189# define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED
1190#endif
1191#ifndef Q_DECL_DEPRECATED_X
1192# define Q_DECL_DEPRECATED_X(text) Q_DECL_DEPRECATED
1193#endif
1194#ifndef Q_DECL_ENUMERATOR_DEPRECATED
1195# define Q_DECL_ENUMERATOR_DEPRECATED
1196#endif
1197#ifndef Q_DECL_ENUMERATOR_DEPRECATED_X
1198# define Q_DECL_ENUMERATOR_DEPRECATED_X(x)
1199#endif
1200#ifndef Q_DECL_EXPORT
1201# define Q_DECL_EXPORT
1202#endif
1203#ifndef Q_DECL_IMPORT
1204# define Q_DECL_IMPORT
1205#endif
1206#ifndef Q_DECL_HIDDEN
1207# define Q_DECL_HIDDEN
1208#endif
1209#ifndef Q_DECL_UNUSED
1210# define Q_DECL_UNUSED
1211#endif
1212#ifndef Q_DECL_UNUSED_MEMBER
1213# define Q_DECL_UNUSED_MEMBER
1214#endif
1215#ifndef Q_FUNC_INFO
1216# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC)
1217# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
1218# else
1219# define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
1220# endif
1221#endif
1222#ifndef Q_DECL_CF_RETURNS_RETAINED
1223# define Q_DECL_CF_RETURNS_RETAINED
1224#endif
1225#ifndef Q_DECL_NS_RETURNS_AUTORELEASED
1226# define Q_DECL_NS_RETURNS_AUTORELEASED
1227#endif
1228#ifndef Q_DECL_PURE_FUNCTION
1229# define Q_DECL_PURE_FUNCTION
1230#endif
1231#ifndef Q_DECL_CONST_FUNCTION
1232# define Q_DECL_CONST_FUNCTION Q_DECL_PURE_FUNCTION
1233#endif
1234#ifndef Q_DECL_COLD_FUNCTION
1235# define Q_DECL_COLD_FUNCTION
1236#endif
1237#ifndef QT_MAKE_UNCHECKED_ARRAY_ITERATOR
1238# define QT_MAKE_UNCHECKED_ARRAY_ITERATOR(x) (x)
1239#endif
1240#ifndef QT_MAKE_CHECKED_ARRAY_ITERATOR
1241# define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) (x)
1242#endif
1243#ifdef __has_feature
1244# define QT_HAS_FEATURE(x) __has_feature(x)
1245#else
1246# define QT_HAS_FEATURE(x) 0
1247#endif
1248
1249/*
1250 * Warning/diagnostic handling
1251 */
1252
1253#define QT_DO_PRAGMA(text) _Pragma(#text)
1254#if defined(Q_CC_INTEL) && defined(Q_CC_MSVC)
1255/* icl.exe: Intel compiler on Windows */
1256# undef QT_DO_PRAGMA /* not needed */
1257# define QT_WARNING_PUSH __pragma(warning(push))
1258# define QT_WARNING_POP __pragma(warning(pop))
1259# define QT_WARNING_DISABLE_MSVC(number)
1260# define QT_WARNING_DISABLE_INTEL(number) __pragma(warning(disable: number))
1261# define QT_WARNING_DISABLE_CLANG(text)
1262# define QT_WARNING_DISABLE_GCC(text)
1263# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1478 1786)
1264#elif defined(Q_CC_INTEL)
1265/* icc: Intel compiler on Linux or OS X */
1266# define QT_WARNING_PUSH QT_DO_PRAGMA(warning(push))
1267# define QT_WARNING_POP QT_DO_PRAGMA(warning(pop))
1268# define QT_WARNING_DISABLE_INTEL(number) QT_DO_PRAGMA(warning(disable: number))
1269# define QT_WARNING_DISABLE_MSVC(number)
1270# define QT_WARNING_DISABLE_CLANG(text)
1271# define QT_WARNING_DISABLE_GCC(text)
1272# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_INTEL(1478 1786)
1273#elif defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
1274# undef QT_DO_PRAGMA /* not needed */
1275# define QT_WARNING_PUSH __pragma(warning(push))
1276# define QT_WARNING_POP __pragma(warning(pop))
1277# define QT_WARNING_DISABLE_MSVC(number) __pragma(warning(disable: number))
1278# define QT_WARNING_DISABLE_INTEL(number)
1279# define QT_WARNING_DISABLE_CLANG(text)
1280# define QT_WARNING_DISABLE_GCC(text)
1281# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_MSVC(4996)
1282#elif defined(Q_CC_CLANG)
1283# define QT_WARNING_PUSH QT_DO_PRAGMA(clang diagnostic push)
1284# define QT_WARNING_POP QT_DO_PRAGMA(clang diagnostic pop)
1285# define QT_WARNING_DISABLE_CLANG(text) QT_DO_PRAGMA(clang diagnostic ignored text)
1286# define QT_WARNING_DISABLE_GCC(text)
1287# define QT_WARNING_DISABLE_INTEL(number)
1288# define QT_WARNING_DISABLE_MSVC(number)
1289# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
1290#elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
1291# define QT_WARNING_PUSH QT_DO_PRAGMA(GCC diagnostic push)
1292# define QT_WARNING_POP QT_DO_PRAGMA(GCC diagnostic pop)
1293# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text)
1294# define QT_WARNING_DISABLE_CLANG(text)
1295# define QT_WARNING_DISABLE_INTEL(number)
1296# define QT_WARNING_DISABLE_MSVC(number)
1297# define QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
1298#else // All other compilers, GCC < 4.6 and MSVC < 2008
1299# define QT_WARNING_DISABLE_GCC(text)
1300# define QT_WARNING_PUSH
1301# define QT_WARNING_POP
1302# define QT_WARNING_DISABLE_INTEL(number)
1303# define QT_WARNING_DISABLE_MSVC(number)
1304# define QT_WARNING_DISABLE_CLANG(text)
1305# define QT_WARNING_DISABLE_GCC(text)
1306# define QT_WARNING_DISABLE_DEPRECATED
1307#endif
1308
1309/*
1310 Proper for-scoping in MIPSpro CC
1311*/
1312#ifndef QT_NO_KEYWORDS
1313# if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64))
1314# define for if (0) {} else for
1315# endif
1316#endif
1317
1318#ifdef Q_COMPILER_RVALUE_REFS
1319#define qMove(x) std::move(x)
1320#else
1321#define qMove(x) (x)
1322#endif
1323
1324#define Q_UNREACHABLE() \
1325 do {\
1326 Q_ASSERT_X(false, "Q_UNREACHABLE()", "Q_UNREACHABLE was reached");\
1327 Q_UNREACHABLE_IMPL();\
1328 } while (false)
1329
1330#define Q_ASSUME(Expr) \
1331 do {\
1332 const bool valueOfExpression = Expr;\
1333 Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\
1334 Q_ASSUME_IMPL(valueOfExpression);\
1335 } while (false)
1336
1337#if defined(__cplusplus)
1338#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
1339# define Q_FALLTHROUGH() [[clang::fallthrough]]
1340#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
1341# define Q_FALLTHROUGH() [[gnu::fallthrough]]
1342#elif QT_HAS_CPP_ATTRIBUTE(fallthrough)
1343# define Q_FALLTHROUGH() [[fallthrough]]
1344#endif
1345#endif
1346#ifndef Q_FALLTHROUGH
1347# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL)
1348# define Q_FALLTHROUGH() __attribute__((fallthrough))
1349# else
1350# define Q_FALLTHROUGH() (void)0
1351#endif
1352#endif
1353
1354
1355/*
1356 Sanitize compiler feature availability
1357*/
1358#if !defined(Q_PROCESSOR_X86)
1359# undef QT_COMPILER_SUPPORTS_SSE2
1360# undef QT_COMPILER_SUPPORTS_SSE3
1361# undef QT_COMPILER_SUPPORTS_SSSE3
1362# undef QT_COMPILER_SUPPORTS_SSE4_1
1363# undef QT_COMPILER_SUPPORTS_SSE4_2
1364# undef QT_COMPILER_SUPPORTS_AVX
1365# undef QT_COMPILER_SUPPORTS_AVX2
1366#endif
1367#if !defined(Q_PROCESSOR_ARM)
1368# undef QT_COMPILER_SUPPORTS_NEON
1369#endif
1370#if !defined(Q_PROCESSOR_MIPS)
1371# undef QT_COMPILER_SUPPORTS_MIPS_DSP
1372# undef QT_COMPILER_SUPPORTS_MIPS_DSPR2
1373#endif
1374
1375#endif // QCOMPILERDETECTION_H
1376