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