summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2014-02-09 03:38:12 +0000
committerRobert Bragg <robert.bragg@intel.com>2014-03-20 17:47:49 +0000
commit0caae111f657a3c442776c00f5a05988807816d4 (patch)
treee96b2404d20ae88f4f462ab514e6094ef17f0966
parentc6b618c21a9dfccdde8cf0f3154b7194fc5a959c (diff)
downloadcogl-0caae111f657a3c442776c00f5a05988807816d4.tar.gz
gmacros: Use _Static_assert for G_STATIC_ASSERT
This now simply defines G_STATIC_ASSERT in terms of _Static_assert if __GNUC__ is defined, and disables the assertion if not. This stops lots of verbose compiler warnings caused by the previous typedef based approach.
-rw-r--r--deps/glib/gmacros.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/deps/glib/gmacros.h b/deps/glib/gmacros.h
index e89b0c6b..115d5d79 100644
--- a/deps/glib/gmacros.h
+++ b/deps/glib/gmacros.h
@@ -145,11 +145,14 @@
#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2)
-#ifdef __COUNTER__
-#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
+
+#if defined (__GNUC__)
+#define G_STATIC_ASSERT(EXPRESSION) \
+ _Static_assert (EXPRESSION, "Static assertion failed: " G_STRINGIFY(EXPRESSION))
#else
-#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1]
+#define G_STATIC_ASSERT(EXPRESSION)
#endif
+
#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1]))
#endif