[Piglit] [PATCH 2/9] cmake: Fix stdbool.h for MSVC 2013.

jfonseca at vmware.com jfonseca at vmware.com
Tue Apr 29 10:57:47 PDT 2014


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

---
 CMakeLists.txt             | 8 +++++++-
 include/msvc/c99/stdbool.h | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b051f7..6f45d2e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -230,7 +230,13 @@ if (NOT MSVC)
 		SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
 	ENDIF (CXX_COMPILER_FLAG_WNO_NARROWING)
 else ()
-	include_directories("include/msvc/c99")
+	# Use bundled stdbool.h and stdint.h headers for older MSVC versions.
+	# stdint.h was introduced in MSVC 2010, but stdbool.h was only
+	# introduced in MSVC 2013.
+	check_include_file (stdbool.h HAVE_STDBOOL_H)
+	if (NOT HAVE_STDBOOL_H)
+		include_directories ("include/msvc/c99")
+	endif ()
 
 	# -Wall or (/Wall) is actually supported by MSVC and would be detected
 	# by CHECK_C_COMPILER_FLAG above, but is very pedantic, causing
diff --git a/include/msvc/c99/stdbool.h b/include/msvc/c99/stdbool.h
index 99a735d..dd55255 100644
--- a/include/msvc/c99/stdbool.h
+++ b/include/msvc/c99/stdbool.h
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2007-2010 VMware, Inc.
+ * Copyright 2007-2014 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,7 +35,7 @@
 #define bool    _Bool
 
 /* For compilers that don't have the builtin _Bool type. */
-#if defined(_MSC_VER) || (__STDC_VERSION__ < 199901L && __GNUC__ < 3)
+#if (defined(_MSC_VER) && _MSC_VER < 1800) || (__STDC_VERSION__ < 199901L && __GNUC__ < 3)
 typedef unsigned char _Bool;
 #endif
 
-- 
1.9.1



More information about the Piglit mailing list