GNOME Bugzilla – Bug 96591
fix prototype of GtkItemFactoryCallback
Last modified: 2004-12-22 21:47:04 UTC
In gtk-2.0/gtk/gtkitemfactory.h please change typedef void (*GtkItemFactoryCallback) (); to typedef void (*GtkItemFactoryCallback) (void); An argument list of "()" means "arguments unspecified", not "no arguments." It's a K&R-C compatibility thing that shouldn't be used in ANSI C or C++ programs. I compile my programs with -Wall -Wstrict-prototypes, and this causes the following warning in every file that includes gtk.h: In file included from /usr/include/gtk-2.0/gtk/gtk.h:90, from ... /usr/include/gtk-2.0/gtk/gtkitemfactory.h:46: warning: function declaration isn't a prototype /usr/include/gtk-2.0/gtk/gtkitemfactory.h from gtk2-devel-2.0.6-8
*** This bug has been marked as a duplicate of 92200 ***
I fail to see how fixing this obvious bug would result in ABI breakage. Please explain.
Owen explained it in buig 92200: For C++, the name mangling will change.
Well, if we changed it as suggested in this bug report, the C++ mangling wouldn't change, but everybody using GtkItemFactory from C would need casts where no casts were necessary before and we'd also be left with an incorrect prototype...
> Well, if we changed it as suggested in this bug report, > the C++ mangling wouldn't change, but everybody using > GtkItemFactory from C would need casts where no casts > were necessary before ...as opposed to today, where correct code gets a warning for every file. > and we'd also be left with an incorrect prototype... In what way would the prototype be incorrect?
GtkItemFactory examples generally look like: static void do_new (gpointer callback_data, guint callback_action, GtkWidget *widget) { create_address_book (); } static GtkItemFactoryEntry menu_items[] = { [...] { "/File/_New", "<Control>N", do_new, 0, NULL }, [...] }; If we make your change, we need '(GtkItemFactoryEntry)do_new' instead. The prototype would be incorrect since ItemFactory callbacks take three arguments not none. (For signal connections, we use a dummy GCallback typedef and require a cast, but that is because different signals take different arguments; that is not the case here.)
Ok, then if a GtkItemFactoryEntry takes three arguments, then change it to be prototyped with three arguments! If you're concerned about C++ prototypes breaking, then wrap the fix inside #ifndef CPLUSPLUS or whatever. But having *correct ANSI C programs* generate warnings just by including this file -- when they aren't even using GtkItemFactoryEntry at all -- is just crazy! Please, stop the insanity.
It's perfectly valid ISO C. Future direction indications in the spec have no indication over whether it's valid or not.
It's also "valid" ANSI C. It does, however, produce an irritating warning. I would really like to eliminate that warning without reducing the warning-level of gcc. Why do you object so strongly to this simple, harmless change?
Hello?