Reputation: 1779
After the upgrade to Glib-2.44 I receive these warnings when I try to compile my software:
In file included from /usr/include/glib-2.0/gobject/gobject.h:24:0,
from /usr/include/glib-2.0/gobject/gbinding.h:29,
from /usr/include/glib-2.0/glib-object.h:23,
from /usr/include/glib-2.0/gio/gioenums.h:28,
from /usr/include/glib-2.0/gio/giotypes.h:28,
from /usr/include/glib-2.0/gio/gio.h:26,
from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:28,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from src/get_file_size.c:1:
/usr/include/glib-2.0/gio/glistmodel.h: In function ‘G_LIST_MODEL’:
/usr/include/glib-2.0/gobject/gtype.h:2186:40: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
^
/usr/include/glib-2.0/gobject/gtype.h:479:66: note: in expansion of macro ‘_G_TYPE_CIC’
#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: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 ‘G_IS_LIST_MODEL’:
/usr/include/glib-2.0/gobject/gtype.h:2200:27: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \
^
/usr/include/glib-2.0/gobject/gtype.h:491:66: note: in expansion of macro ‘_G_TYPE_CIT’
#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type)))
^
/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 ‘G_LIST_MODEL_GET_IFACE’:
/usr/include/glib-2.0/gobject/gtype.h:2196:72: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
#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:533:66: note: in expansion of macro ‘_G_TYPE_IGI’
#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: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 ‘G_LIST_STORE’:
/usr/include/glib-2.0/gobject/gtype.h:2186:40: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
^
/usr/include/glib-2.0/gobject/gtype.h:479:66: note: in expansion of macro ‘_G_TYPE_CIC’
#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: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 ‘G_IS_LIST_STORE’:
/usr/include/glib-2.0/gobject/gtype.h:2200:27: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \
^
/usr/include/glib-2.0/gobject/gtype.h:491:66: note: in expansion of macro ‘_G_TYPE_CIT’
#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type)))
^
/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)
This is the source code of a function (I receive the same warnings also from other different functions, this is one of them):
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gstdio.h>
goffset
get_file_size (const gchar *file_path)
{
GFileInfo *info;
GFile *file;
GError *error = NULL;
const gchar *attributes = "standard::*";
GFileQueryInfoFlags flags = G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS;
GCancellable *cancellable = NULL;
goffset file_size;
file = g_file_new_for_path (file_path);
info = g_file_query_info (file, attributes, flags, cancellable, &error);
file_size = g_file_info_get_size (info);
g_object_unref(file);
return file_size;
}
I know that I can avoid them using -Wno-cast-qual
but I don't want to do this. With Glib-2.42 I didn't have these kinds of problem.
I cannot understand how to solve this warning because I'm not receiving it on a specific piece of code.
Any idea?
Upvotes: 0
Views: 469
Reputation: 8815
The warning is coming from the redefinition of the GListStore
and GListModel
structures inside GIO itself, not from your code. This is valid C11, as well as valid with recent versions of GCC, but older compilers will emit a warning.
This issue has recently been fixed in GLib itself, and the warning will be be gone in GLib 2.44.1, once it's released.
Upvotes: 1