GNOME Bugzilla – Bug 756005
glib-2.0.pc.in should use '-isystem dir' rather than '-Idir'
Last modified: 2018-05-24 18:14:50 UTC
Created attachment 312594 [details] [review] Patch to fix 3rd party projects that use glib and build with gcc -Werror enabled glib produces warnings in that gcc will turn to errors when a project builds with -Werror: /usr/include/glib-2.0/gio/glistmodel.h: In function 'GListModel* G_LIST_MODEL(gconstpointer)': /usr/include/glib-2.0/gobject/gtype.h:479:88: error: cast from type 'gconstpointer {aka const void*}' to type 'GTypeInstance* {aka _GTypeInstance*}' casts away qualifiers [-Werror=cast-qual] #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) ^ /usr/include/glib-2.0/gobject/gtype.h:2186:57: note: in definition of macro '_G_TYPE_CIC' ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) ^ /usr/include/glib-2.0/gobject/gtype.h:1565:12: note: in expansion of macro 'G_TYPE_CHECK_INSTANCE_CAST' return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ ^ /usr/include/glib-2.0/gio/glistmodel.h:36:1: note: in expansion of macro 'G_DECLARE_INTERFACE' G_DECLARE_INTERFACE(GListModel, g_list_model, G, LIST_MODEL, GObject) ^ /usr/include/glib-2.0/gio/glistmodel.h: In function 'gboolean G_IS_LIST_MODEL(gconstpointer)': /usr/include/glib-2.0/gobject/gtype.h:491:88: error: cast from type 'gconstpointer {aka const void*}' to type 'GTypeInstance* {aka _GTypeInstance*}' casts away qualifiers [-Werror=cast-qual] #define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type))) ^ /usr/include/glib-2.0/gobject/gtype.h:2200:44: note: in definition of macro '_G_TYPE_CIT' GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \ ^ /usr/include/glib-2.0/gobject/gtype.h:1567:12: note: in expansion of macro 'G_TYPE_CHECK_INSTANCE_TYPE' return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ ^ /usr/include/glib-2.0/gio/glistmodel.h:36:1: note: in expansion of macro 'G_DECLARE_INTERFACE' G_DECLARE_INTERFACE(GListModel, g_list_model, G, LIST_MODEL, GObject) ^ /usr/include/glib-2.0/gio/glistmodel.h: In function 'GListModelInterface* G_LIST_MODEL_GET_IFACE(gconstpointer)': /usr/include/glib-2.0/gobject/gtype.h:533:88: error: cast from type 'gconstpointer {aka const void*}' to type 'GTypeInstance* {aka _GTypeInstance*}' casts away qualifiers [-Werror=cast-qual] #define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type)) ^ /usr/include/glib-2.0/gobject/gtype.h:2196:89: note: in definition of macro '_G_TYPE_IGI' #define _G_TYPE_IGI(ip, gt, ct) ((ct*) g_type_interface_peek (((GTypeInstance*) ip)->g_class, gt)) ^ /usr/include/glib-2.0/gobject/gtype.h:1569:12: note: in expansion of macro 'G_TYPE_INSTANCE_GET_INTERFACE' return G_TYPE_INSTANCE_GET_INTERFACE (ptr, module_obj_name##_get_type (), ModuleObjName##Interface); } \ ^ /usr/include/glib-2.0/gio/glistmodel.h:36:1: note: in expansion of macro 'G_DECLARE_INTERFACE' G_DECLARE_INTERFACE(GListModel, g_list_model, G, LIST_MODEL, GObject) ^ /usr/include/glib-2.0/gio/gliststore.h: In function 'GListStore* G_LIST_STORE(gconstpointer)': /usr/include/glib-2.0/gobject/gtype.h:479:88: error: cast from type 'gconstpointer {aka const void*}' to type 'GTypeInstance* {aka _GTypeInstance*}' casts away qualifiers [-Werror=cast-qual] #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) ^ /usr/include/glib-2.0/gobject/gtype.h:2186:57: note: in definition of macro '_G_TYPE_CIC' ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) ^ /usr/include/glib-2.0/gobject/gtype.h:1396:12: note: in expansion of macro 'G_TYPE_CHECK_INSTANCE_CAST' return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ ^ /usr/include/glib-2.0/gio/gliststore.h:36:1: note: in expansion of macro 'G_DECLARE_FINAL_TYPE' G_DECLARE_FINAL_TYPE(GListStore, g_list_store, G, LIST_STORE, GObject) ^ /usr/include/glib-2.0/gio/gliststore.h: In function 'gboolean G_IS_LIST_STORE(gconstpointer)': /usr/include/glib-2.0/gobject/gtype.h:491:88: error: cast from type 'gconstpointer {aka const void*}' to type 'GTypeInstance* {aka _GTypeInstance*}' casts away qualifiers [-Werror=cast-qual] #define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type))) ^ /usr/include/glib-2.0/gobject/gtype.h:2200:44: note: in definition of macro '_G_TYPE_CIT' GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \ ^ /usr/include/glib-2.0/gobject/gtype.h:1398:12: note: in expansion of macro 'G_TYPE_CHECK_INSTANCE_TYPE' return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ ^ /usr/include/glib-2.0/gio/gliststore.h:36:1: note: in expansion of macro 'G_DECLARE_FINAL_TYPE' G_DECLARE_FINAL_TYPE(GListStore, g_list_store, G, LIST_STORE, GObject) ^ suppress these by using -isystem dir to include the directories so that a project using these headers compiled with -Werror doesn't fail
Comment on attachment 312594 [details] [review] Patch to fix 3rd party projects that use glib and build with gcc -Werror enabled This would make the .pc file gcc-specific
I'm pretty sure that adding -isystem is going to prevent GCC from warning in other, more important, macros — see bug 753310 for the removal of the system_header pragma that masked real warnings in projects using GLib. If we can, we should fix the macros instead of playing games with compiler flags. As a side note: my strong opinion is that building with a blanket -Werror is a disaster waiting to happen, a mistake, and nobody should *ever* do that, unless they have full control of the whole stack of dependencies. You should select the warnings you care about enough to break the build using -Werror=foo — otherwise, it's just a race to the bottom between dependencies and a compiler adding new (and "interesting") warnings that may or may not be false positives.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1086.