[cogl/wip/public-atlas-apis: 4/13] gmacros: Use _Static_assert for G_STATIC_ASSERT



commit d2a2f70f81a4a61abdb1870baff4db75015b4241
Author: Robert Bragg <robert linux intel com>
Date:   Sun Feb 9 03:38:12 2014 +0000

    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.

 deps/glib/gmacros.h |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/deps/glib/gmacros.h b/deps/glib/gmacros.h
index e89b0c6..115d5d7 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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]