After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 310175 - g_signal_handlers_disconnect_by_func triggers compile time warning when '-Wall -ansi -pedantic' compiler flags
g_signal_handlers_disconnect_by_func triggers compile time warning when '-Wal...
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: gobject
2.6.x
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 310216
 
 
Reported: 2005-07-12 21:13 UTC by Priit Laes (IRC: plaes)
Modified: 2005-07-27 14:30 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement



Description Priit Laes (IRC: plaes) 2005-07-12 21:13:48 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 *'
Comment 1 Owen Taylor 2005-07-12 21:43:57 UTC
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 ]
Comment 2 Priit Laes (IRC: plaes) 2005-07-13 09:01:36 UTC
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.
Comment 3 Owen Taylor 2005-07-13 13:53:56 UTC
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)

Comment 4 Owen Taylor 2005-07-27 14:30:24 UTC
Hmm, I didn't notice that you reopened this bug. PLEASE LEAVE IT CLOSED.
IT IS NOT A COMPATIBLE CHANGE.

Thanks.