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