[glib] USE __COUNTER__ instead of __LINE__ when available



commit 97b0b36ae39d5eb087315259ff56c799271b28c3
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Oct 7 01:19:15 2011 -0400

    USE __COUNTER__ instead of __LINE__ when available
    
    I've seen builds fail with
    
    nm-connection.c:119:691: error: declaration of '_GStaticAssertCompileTimeAssertion_119' shadows a previous local [-Werror=shadow]
    
    because several compile-time assertions ended up on the same
    line. __COUNTER__ is meant specifically for the purpose of
    constructing identifiers, so use it when available.

 glib/gmacros.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/glib/gmacros.h b/glib/gmacros.h
index d8ab4fa..50a03ed 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -147,7 +147,11 @@
 #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]
+#else
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1]
+#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]