GNOME Bugzilla – Bug 691107
G_STATIC_ASSERT fails to build on gcc 4.8 due to -Wunused-local-typedefs
Last modified: 2013-04-06 15:27:00 UTC
G_STATIC_ASSERT uses a typedef _GStaticAssertCompileTimeAssertion_1 which is later unused, and fails to build with -Werror on gcc 4.8: /usr/include/glib-2.0/glib/gmacros.h:162:53: warning: typedef ‘_GStaticAssertCompileTimeAssertion_0’ locally defined but not used [-Wunused-local-typedefs] #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] ^ /usr/include/glib-2.0/glib/gmacros.h:159:47: note: in definition of macro ‘G_PASTE_ARGS’ #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 ^ /usr/include/glib-2.0/glib/gmacros.h:162:44: note: in expansion of macro ‘G_PASTE’ #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] ^ /usr/include/glib-2.0/glib/gthread.h:234:5: note: in expansion of macro ‘G_STATIC_ASSERT’ G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ ^ /usr/include/glib-2.0/gobject/gtype.h:1463:7: note: in expansion of macro ‘g_once_init_enter’ if (g_once_init_enter (&g_define_type_id__volatile)) \ ^ /usr/include/glib-2.0/gobject/gtype.h:1294:56: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_BEGIN’ #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() ^ /home/mcr2010/src/bzr/compiz/gtk/window-decorator/gwd-settings-notified.c:51:1: note: in expansion of macro ‘G_DEFINE_TYPE_WITH_CODE’ G_DEFINE_TYPE_WITH_CODE (GWDSettingsNotifiedImpl, gwd_settings_notified_impl, G_TYPE_OBJECT, ^ /usr/include/glib-2.0/glib/gmacros.h:162:53: warning: typedef ‘_GStaticAssertCompileTimeAssertion_1’ locally defined but not used [-Wunused-local-typedefs] #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] ^ /usr/include/glib-2.0/glib/gmacros.h:159:47: note: in definition of macro ‘G_PASTE_ARGS’ #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 ^ /usr/include/glib-2.0/glib/gmacros.h:162:44: note: in expansion of macro ‘G_PASTE’ #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] ^ /usr/include/glib-2.0/glib/gatomic.h:136:5: note: in expansion of macro ‘G_STATIC_ASSERT’ G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ ^ /usr/include/glib-2.0/glib/gthread.h:236:7: note: in expansion of macro ‘g_atomic_pointer_get’ (!g_atomic_pointer_get (location) && \ ^ /usr/include/glib-2.0/gobject/gtype.h:1463:7: note: in expansion of macro ‘g_once_init_enter’ if (g_once_init_enter (&g_define_type_id__volatile)) \ ^ /usr/include/glib-2.0/gobject/gtype.h:1294:56: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_BEGIN’ #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() ^ /home/mcr2010/src/bzr/compiz/gtk/window-decorator/gwd-settings-notified.c:51:1: note: in expansion of macro ‘G_DEFINE_TYPE_WITH_CODE’ G_DEFINE_TYPE_WITH_CODE (GWDSettingsNotifiedImpl, gwd_settings_notified_impl, G_TYPE_OBJECT, ^ /usr/include/glib-2.0/glib/gmacros.h:162:53: warning: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Wunused-local-typedefs] #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] ^ /usr/include/glib-2.0/glib/gmacros.h:159:47: note: in definition of macro ‘G_PASTE_ARGS’ #define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 ^ /usr/include/glib-2.0/glib/gmacros.h:162:44: note: in expansion of macro ‘G_PASTE’ #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] ^ /usr/include/glib-2.0/glib/gthread.h:241:5: note: in expansion of macro ‘G_STATIC_ASSERT’ G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ ^ /usr/include/glib-2.0/gobject/gtype.h:1477:7: note: in expansion of macro ‘g_once_init_leave’ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); \ ^ /usr/include/glib-2.0/gobject/gtype.h:1294:111: note: in expansion of macro ‘_G_DEFINE_TYPE_EXTENDED_END’ #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() ^ /home/mcr2010/src/bzr/compiz/gtk/window-decorator/gwd-settings-notified.c:51:1: note: in expansion of macro ‘G_DEFINE_TYPE_WITH_CODE’ G_DEFINE_TYPE_WITH_CODE (GWDSettingsNotifiedImpl, gwd_settings_notified_impl, G_TYPE_OBJECT, ^
I pity the fool who uses -Werror Seriously, though. See bug 686773 for the most plausible way out of this mess... *** This bug has been marked as a duplicate of bug 686773 ***
Ah, I thought there might have been a dupe, but searching for gcc 4.8 didn't show it. Cheers.
Created attachment 240843 [details] [review] Fix "unused local typedef" warning in G_STATIC_ASSERT I don't see why we need _Static_assert to solve this. Is there a problem with just adding G_GNUC_UNUSED to the typedef? Please reopen.