Re: Unidentified subject!
- From: Erik Mouw <J A K Mouw its tudelft nl>
- To: gtk-devel-list redhat com
- Subject: Re: Unidentified subject!
- Date: Mon, 17 Jan 2000 13:58:12 +0100 (MET)
On Sun, 16 Jan 2000 13:57:25 -0800 (PST), Kaz Kylheku wrote:
> On Sun, 16 Jan 2000, Jeroen Ruigrok/Asmodai wrote:
>> >
>> >typedef void (*GtkItemFactoryCallback) ();
>> >
>> >to
>> >
>> >typedef void (*GtkItemFactoryCallback) (void);
>>
>> I mistook them for empty braces. But I understand these should be
>> variable argument cases. Am I correct in this assumption?
>
> No. The way to declare a variadic function in C and C++ is to use ellipses. An
> empty parameter list in C++ declares a function that takes no parameters, like
> the (void) list in ANSI C. An empty parameter list in C declares a function
> which takes a fixed number of arguments, but does not specify that number, or
> their types.
Sorry, but that's not correct. A declaration like 'int foo()' means that
it is a K&R style function declaration. K&R C didn't have a way to specify
"unspecified number of arguments", so printf could be declared like "int
printf()".
ANSI C introduced a stricter function prototype in which you had to
specify the exact number of parameters. Functions like printf() didn't fit
in this scheme, so the ellipsis notation was invented: "int printf(const
char *format, ...)". See section A7.3.2 "Function Calls" from "The C
Programming Language, second edition" by Kernighan and Ritchie.
As far as I understand from gtkitemfactory.h, GtkItemFactoryCallback is
used a placeholder for two different types of callback functions:
typedef void (*GtkItemFactoryCallback1) (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
typedef void (*GtkItemFactoryCallback2) (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
Unfortunately, those two types don't share the same first parameter, so it
is impossible to make a vararg function.
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]