Loosen checks for Q_COMPILER_VARIADIC_MACROS

So far we did bind the definition of Q_COMPILER_VARIADIC_MACROS to
C++11 (so gcc, clang will not define it in default gnu++98 standard).
However, variadic macros are a feature of the gcc preprocessor since
version 2.97, and are enabled in the default configurations on gcc, clang,
icc.

This might cause warnings and errors though if one enables additional
warnings in gcc, clang (e.g. by -pedantic). Anyhow, as a precedent
qglobal.h already relies on  'long long' ... The warning can be disabled
by adding '-Wno-variadic-macros'.

[ChangeLog][Compiler Specific Changes] Variadic macros are now enabled
more liberally for gcc, clang, icc. If you have warnings (because you e.g.
compile with -pedantic), disable them by -Wno-variadic-macros.

Change-Id: Ie979b85809508ad70cab75e6981f20496429f463
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Kai Koehne 2014-01-10 13:19:55 +01:00 committed by The Qt Project
parent d641792ff2
commit 22f0dc4f89
2 changed files with 21 additions and 3 deletions

View File

@ -489,6 +489,7 @@
#ifdef Q_CC_INTEL
# define Q_COMPILER_RESTRICTED_VLA
# define Q_COMPILER_VARIADIC_MACROS // C++11 feature supported as an extension in other modes, too
# if __INTEL_COMPILER < 1200
# define Q_NO_TEMPLATE_FRIENDS
# endif
@ -498,7 +499,6 @@
# define Q_COMPILER_BINARY_LITERALS
# endif
# if __cplusplus >= 201103L
# define Q_COMPILER_VARIADIC_MACROS
# if __INTEL_COMPILER >= 1200
# define Q_COMPILER_AUTO_TYPE
# define Q_COMPILER_CLASS_ENUM
@ -560,6 +560,15 @@
# define Q_COMPILER_BINARY_LITERALS
# endif
// Variadic macros are supported for gnu++98, c++11, c99 ... since 2.9
# if ((__clang_major__ * 100) + __clang_minor__) >= 209
# if !defined(__STRICT_ANSI__) || defined(__GXX_EXPERIMENTAL_CXX0X__) \
|| (defined(__cplusplus) && (__cplusplus >= 201103L)) \
|| (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
# define Q_COMPILER_VARIADIC_MACROS
# endif
# endif
/* C++11 features, see http://clang.llvm.org/cxx_status.html */
# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
/* Detect C++ features using __has_feature(), see http://clang.llvm.org/docs/LanguageExtensions.html#cxx11 */
@ -656,7 +665,6 @@
/* Features that have no __has_feature() check */
# if ((__clang_major__ * 100) + __clang_minor__) >= 209 /* since clang 2.9 */
# define Q_COMPILER_EXTERN_TEMPLATES
# define Q_COMPILER_VARIADIC_MACROS
# endif
# endif
@ -693,13 +701,18 @@
// GCC supports binary literals in C, C++98 and C++11 modes
# define Q_COMPILER_BINARY_LITERALS
# endif
# if !defined(__STRICT_ANSI__) || defined(__GXX_EXPERIMENTAL_CXX0X__) \
|| (defined(__cplusplus) && (__cplusplus >= 201103L)) \
|| (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
// Variadic macros are supported for gnu++98, c++11, C99 ... since forever (gcc 2.97)
# define Q_COMPILER_VARIADIC_MACROS
# endif
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
/* C++11 features supported in GCC 4.3: */
# define Q_COMPILER_DECLTYPE
# define Q_COMPILER_RVALUE_REFS
# define Q_COMPILER_STATIC_ASSERT
# define Q_COMPILER_VARIADIC_MACROS
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
/* C++11 features supported in GCC 4.4: */

View File

@ -55,6 +55,11 @@
# define TST_QMETATYPE_BROKEN_COMPILER
#endif
// mingw gcc 4.8 also takes way too long, letting the CI system abort the test
#if defined(__MINGW32__)
# define TST_QMETATYPE_BROKEN_COMPILER
#endif
Q_DECLARE_METATYPE(QMetaType::Type)
class tst_QMetaType: public QObject