[Piglit] [PATCH] cmake: Enforce standard C99 syntax for variadic macros.

Jose Fonseca jfonseca at vmware.com
Wed Feb 18 05:36:49 PST 2015

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.
 CMakeLists.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4236c89..420f76f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -214,6 +214,17 @@ if (NOT MSVC)
 	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)
+		set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=variadic-macros")
+	endif ()

More information about the Piglit mailing list