[Piglit] [PATCH 1/2] cmake: Warn when placing declarations after statements.

jfonseca at vmware.com jfonseca at vmware.com
Tue Jan 17 11:29:10 PST 2012

From: José Fonseca <jfonseca at vmware.com>

Unfortunately this will enable the warning even on OS specific directories
will never be built with MSVC, but it looks like the use of this C99 is
actually very scarce, even on those OS specific directories.
 CMakeLists.txt |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 179340e..d4b5b2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,6 +56,14 @@ if (NOT MSVC)
+	# Unfortunately MSVC does not support C99.  Among all features enabled
+	# by C99, declarations after statements is the most frequently used.
+	# For portability sake, we request gcc to warn when this is used.
+		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
 else ()
 	# -Wall or (/Wall) is actually supported by MSVC and would be detected
 	# by CHECK_C_COMPILER_FLAG above, but is very pedantic, causing

More information about the Piglit mailing list