From 37a660c594a6de1a99833a539adbef0495a90548 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 Jul 2012 14:52:20 +0200 Subject: qcompilerdetection.h: set Q_DECL_OVERRIDE/Q_DECL_FINAL for 2005 <= MSVC <= 2010 This enables Q_DECL_FINAL and Q_DECL_OVERRIDE backed by VC's non-standard extensions from VC 2005 on. VC 2012 will support the standard-compliant version, so use that there. Change-Id: I96874fe3d36fcaa283d2d1f53d5eb6825e55f259 Reviewed-by: Olivier Goffart --- src/corelib/global/qcompilerdetection.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index f1d4a8a51d..b76a2ed978 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -646,6 +646,15 @@ # if _MSC_VER >= 1400 /* C++11 features supported in VC8 = VC2005: */ # define Q_COMPILER_VARIADIC_MACROS + /* 2005 supports the override and final contextual keywords, in + the same positions as the C++11 variants, but 'final' is + called 'sealed' instead: + http://msdn.microsoft.com/en-us/library/0w2w91tf%28v=vs.80%29.aspx + So don't define Q_COMPILER_EXPLICIT_OVERRIDES (since it's not + the same as the C++11 version), but define the Q_DECL_* flags + accordingly: */ +# define Q_DECL_OVERRIDE override +# define Q_DECL_FINAL sealed # endif # if _MSC_VER >= 1600 /* C++11 features supported in VC10 = VC2010: */ @@ -659,7 +668,9 @@ # endif # if _MSC_VER >= 1700 /* C++11 features supported in VC11 = VC2012: */ -# define Q_COMPILER_EXPLICIT_OVERRIDES +# undef Q_DECL_OVERRIDE /* undo 2005/2098 settings... */ +# undef Q_DECL_FINAL /* undo 2005/2008 settings... */ +# define Q_COMPILER_EXPLICIT_OVERRIDES /* ...and use std C++11 now */ # define Q_COMPILER_RANGE_FOR # define Q_COMPILER_CLASS_ENUM # define Q_COMPILER_ATOMICS @@ -716,8 +727,12 @@ # define Q_DECL_OVERRIDE override # define Q_DECL_FINAL final #else -# define Q_DECL_OVERRIDE -# define Q_DECL_FINAL +# ifndef Q_DECL_OVERRIDE +# define Q_DECL_OVERRIDE +# endif +# ifndef Q_DECL_FINAL +# define Q_DECL_FINAL +# endif #endif #ifdef Q_COMPILER_NOEXCEPT -- cgit v1.2.3