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