From b5153d5bfab63da811b7a4615238d9e50198b412 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 18 Jul 2016 16:34:22 -0700 Subject: Windows: Disable unsupported C++11 features with Clang-cl and ICC Whenever someone installs Clang or the Intel compiler on Windows, it's very likely that the compiler will be much newer than the MS headers that came with the installed Visual Studio version. So let's make sure we disable the C++11 features that the MS headers don't support properly. For example, MS's header supplied with VS 2013 doesn't mark the max() function as constexpr, resulting compiler errors in uses of that function in Qt code declared with Q_DECL_CONSTEXPR: qdeadlinetimer.h(62,13) : note: non-constexpr function 'max' cannot be used in a constant expression : s(std::numeric_limits::max()), ns(0), type(type_) {} ^ Change-Id: I149e0540c00745fe8119fffd146286ffe480d216 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 33e42a944d..e152786d3f 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1031,6 +1031,33 @@ // critical definitions. (Reported as Intel Issue ID 6000117277) # define __USE_CONSTEXPR 1 # define __USE_NOEXCEPT 1 +# elif defined(Q_CC_MSVC) && (defined(Q_CC_CLANG) || defined(Q_CC_INTEL)) +// Clang and the Intel compiler support more C++ features than the Microsoft compiler +// so make sure we don't enable them if the MS headers aren't properly adapted. +# ifndef _HAS_CONSTEXPR +# undef Q_COMPILER_CONSTEXPR +# endif +# ifndef _HAS_DECLTYPE +# undef Q_COMPILER_DECLTYPE +# endif +# ifndef _HAS_INITIALIZER_LISTS +# undef Q_COMPILER_INITIALIZER_LISTS +# endif +# ifndef _HAS_NULLPTR_T +# undef Q_COMPILER_NULLPTR +# endif +# ifndef _HAS_RVALUE_REFERENCES +# undef Q_COMPILER_RVALUE_REFS +# endif +# ifndef _HAS_SCOPED_ENUM +# undef Q_COMPILER_CLASS_ENUM +# endif +# ifndef _HAS_TEMPLATE_ALIAS +# undef Q_COMPILER_TEMPLATE_ALIAS +# endif +# ifndef _HAS_VARIADIC_TEMPLATES +# undef Q_COMPILER_VARIADIC_TEMPLATES +# endif # elif defined(_LIBCPP_VERSION) // libc++ uses __has_feature(cxx_atomic), so disable the feature if the compiler // doesn't support it. That's required for the Intel compiler 14.x or earlier on OS X, for example. -- cgit v1.2.3