GNOME Bugzilla – Bug 310175
g_signal_handlers_disconnect_by_func triggers compile time warning when '-Wall -ansi -pedantic' compiler flags
Last modified: 2005-07-27 14:30:24 UTC
Following test program does not compile when using following gcc flags: -Wall -ansi -pedantic -Werror /* SNIP */ #include <gtk/gtk.h> #include <glib.h> static void testfunction () { } int main (int argc, char *argv[]) { GtkWidget *object; g_signal_handlers_disconnect_by_func(G_OBJECT(object), G_CALLBACK(testfunction), NULL); return FALSE; } /* SNIP */ Output: amd@dma ~/code/bug $ gcc `pkg-config --cflags glib-2.0,gtk+-2.0` -Wall -ansi -pedantic -Werror test.c test.c: In function `main': test.c:8: warning: ISO C forbids passing arg 6 of `g_signal_handlers_disconnect_matched' between function pointer and `void *'
You need to use (gpointer)testfunction, not G_CALLBACK(testfunction.) [ Yes, the API was screwed up, but it wasn't noticed until after GLib-2.0.0 was released ]
using (gpointer) testfunction I get: warning: ISO C forbids conversion of function pointer to object pointer type One solution would be using GCC's __extension__keyword in front of the expression, but I think there could be better ones.
In any case, if it's API compatibility vs. Supporting -ansi -pedantic We'll pick API compat every time. (I've never seen -ansi -pedantic be worth more than the trouble they cause)
Hmm, I didn't notice that you reopened this bug. PLEASE LEAVE IT CLOSED. IT IS NOT A COMPATIBLE CHANGE. Thanks.