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 96591 - fix prototype of GtkItemFactoryCallback
fix prototype of GtkItemFactoryCallback
Status: RESOLVED DUPLICATE of bug 92200
Product: gtk+
Classification: Platform
Component: Widget: Other
2.0.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2002-10-23 11:41 UTC by Jamie Zawinski
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.0



Description Jamie Zawinski 2002-10-23 11:41:20 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
Comment 1 Matthias Clasen 2002-10-23 12:18:17 UTC

*** This bug has been marked as a duplicate of 92200 ***
Comment 2 Jamie Zawinski 2002-10-23 12:21:28 UTC
I fail to see how fixing this obvious bug would result in ABI breakage.
Please explain.
Comment 3 Matthias Clasen 2002-10-23 13:21:37 UTC
Owen explained it in buig 92200: For C++, the name mangling will change.
Comment 4 Owen Taylor 2002-10-23 14:09:33 UTC
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...
Comment 5 Jamie Zawinski 2002-10-23 20:22:06 UTC
> 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?
Comment 6 Owen Taylor 2002-10-31 21:51:35 UTC
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.)

Comment 7 Jamie Zawinski 2002-10-31 22:00:40 UTC
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.
Comment 8 Owen Taylor 2002-11-01 00:17:40 UTC
It's perfectly valid ISO C. Future direction indications
in the spec have no indication over whether it's valid
or not.
Comment 9 Jamie Zawinski 2002-11-01 00:50:32 UTC
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?
Comment 10 Jamie Zawinski 2002-11-19 22:57:10 UTC
Hello?