I have a ktype variable const char *, and a function in glib with a prototype
void g_hash_table_replace(GHashTable *hash_table,
gpointer key,
gpointer value);
gpointer defined simply as
typedef void* gpointer;
I know that in this case, in fact, you can pass kin as the key in g_hash_table_replace, however gcc gives me an error
service.c:49:3: warning: passing argument 2 of ‘g_hash_table_replace’ discards ‘const’ qualifier from pointer target type [enabled by default]
/usr/include/glib-2.0/glib/ghash.h:70:13: note: expected ‘gpointer’ but argument is of type ‘const char *’
this is with gcc 4.6.0. With 4.5.0 and earlier, just clicking on (char *) is enough to suppress this warning, but gcc seems to have gotten smarter. I tried (char *)(void *)k, but he still knows that there was originally a variable const. How can I turn off this warning without calling strdup(3)on k?
source
share