GNOME Bugzilla – Bug 648426
Add G_STATIC_ASSERT_EXPR()
Last modified: 2011-05-22 17:10:55 UTC
glib provides G_STATIC_ASSERT(cond) which expands to a typedef. That's useful in global scope, but cannot be used, eg, in macros expanding to an expression or statement. For example, from gatomic.h: # define g_atomic_int_get(atomic) \ ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gint) ? 1 : -1]), \ (g_atomic_int_get) ((volatile gint G_GNUC_MAY_ALIAS *) (volatile void *) (atomic))) The first line in there is essentially and expression version of G_STATIC_ASSERT(). So I suggest we add the following macro (and use it in gatomic.h too): #define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1: -1]))
*** This bug has been marked as a duplicate of bug 626549 ***
Boy, I may have a bad memory, but I like my consistency :D