From 435d7a2c9a410e2771e3b6417f3acfc6cc9f711f Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Wed, 18 Feb 2015 13:29:19 +0000 Subject: cmake: Enforce standard C99 syntax for variadic macros. Although the non-standard GCC syntax has some nice properties, for most practical cases the standard C99 syntax is perfectly fine. Particuarly for printf-like macros, which pretty much account for most the uses of variadic macros in piglit. Unfortunately this will only be effective on newer GCC versions, due a bug in GCC. See comment for more details. Reviewed-by: Roland Scheidegger --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 4236c89ae..420f76f36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,17 @@ if (NOT MSVC) IF (C_COMPILER_FLAG_WVLA) SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wvla") ENDIF () + # MSVC only supports C99 variadic macros. It doesn't support the + # non-standard GNU named variadic macro syntax that's documented in + # https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html + # + # XXX: on older GCC version this option has no effect unless -Wpedantic + # is set, but this should be fixed on future GCC versions, per + # https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01459.html + check_c_compiler_flag ("-Werror=variadic-macros" C_COMPILER_FLAG_WVARIADIC_MACROS) + if (C_COMPILER_FLAG_WVARIADIC_MACROS) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=variadic-macros") + endif () CHECK_CXX_COMPILER_FLAG("-Wno-narrowing" CXX_COMPILER_FLAG_WNO_NARROWING) IF (CXX_COMPILER_FLAG_WNO_NARROWING) -- cgit v1.2.3