Mesa (master): include: Fix build with VS 11 (i.e, 2012).

Jose Fonseca jrfonseca at kemper.freedesktop.org
Tue Mar 12 22:07:38 UTC 2013


Module: Mesa
Branch: master
Commit: 57cd1d1454653f778837eec0ee5d4060bc59c5ba
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=57cd1d1454653f778837eec0ee5d4060bc59c5ba

Author: José Fonseca <jfonseca at vmware.com>
Date:   Tue Mar 12 20:37:47 2013 +0000

include: Fix build with VS 11 (i.e, 2012).

NOTE: Candidate for the stable branches.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 include/c99_compat.h |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/include/c99_compat.h b/include/c99_compat.h
index 39f958f..3a9f502 100644
--- a/include/c99_compat.h
+++ b/include/c99_compat.h
@@ -30,6 +30,37 @@
 
 
 /*
+ * MSVC hacks.
+ */
+#if defined(_MSC_VER)
+   /*
+    * Visual Studio 2012 will complain if we define the `inline` keyword, but
+    * actually it only supports the keyword on C++.
+    *
+    * We could skip this check by defining _ALLOW_KEYWORD_MACROS, but there is
+    * probably value in checking this for other keywords.  So simply include
+    * the checking before we define it below.
+    */
+#  if _MSC_VER >= 1700
+#    include <xkeycheck.h>
+#  endif
+
+   /*
+    * XXX: MSVC has a `__restrict` keyword, but it also has a
+    * `__declspec(restrict)` modifier, so it is impossible to define a
+    * `restrict` macro without interfering with the latter.  Furthermore the
+    * MSVC standard library uses __declspec(restrict) under the _CRTRESTRICT
+    * macro.  For now resolve this issue by redefining _CRTRESTRICT, but going
+    * forward we should probably should stop using restrict, especially
+    * considering that our code does not obbey strict aliasing rules any way.
+    */
+#  include <crtdefs.h>
+#  undef _CRTRESTRICT
+#  define _CRTRESTRICT
+#endif
+
+
+/*
  * C99 inline keyword
  */
 #ifndef inline
@@ -102,4 +133,15 @@
 #endif
 
 
+/* Simple test case for debugging */
+#if 0
+static inline const char *
+test_c99_compat_h(const void * restrict a,
+                  const void * restrict b)
+{
+   return __func__;
+}
+#endif
+
+
 #endif /* _C99_COMPAT_H_ */




More information about the mesa-commit mailing list