From 97b0b36ae39d5eb087315259ff56c799271b28c3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 7 Oct 2011 01:19:15 -0400 Subject: [PATCH] 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 file changed, 4 insertions(+) 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 -- 2.7.4