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