typedefs and prototypes
Griff Smith
ggs at ulysses.homer.nj.att.com
Thu Sep 22 09:52:30 AEST 1988
In article <7135 at bloom-beacon.MIT.EDU>, tada at athena.mit.edu (Michael Zehr) writes:
>
> I'm writing a graphics interface library which ends up passing a lot
> of pointers to functions. I've run into a problem with
> typedefs and prototypes:
> /* typedef and prototype declaration of a widget */
>
> typedef void (*Keyboard_widget)(int key, void *data);
>
> Keyboard_widget kb_widget1;
>
> /* definition of a widget */
>
> void kb_widget1(int c, void *data)
> {...}
> I get a "conflicts with previous declaration" at that point. If I try
> to define the widget by the typedef, what syntax do i use???
/* Define the layout of a keyboard_widget function */
typedef void kb_widg_fn(int key, void *data);
/* Define a type that is a pointer to a keyboard_widget function */
typedef kb_widg_fn* Keyboard_widget;
/* I'm going to use kb_widget1, which is a keyboard_widget function */
kb_widg_fn kb_widget1;
/* And here it is */
void kb_widget1(int c, void *data) {}
/* This is accepted by C++, release 2.0; I can't speak for ANSI C */
--
Griff Smith AT&T (Bell Laboratories), Murray Hill
Phone: 1-201-582-7736
UUCP: {allegra|ihnp4}!ulysses!ggs
Internet: ggs at ulysses.att.com
More information about the Comp.lang.c
mailing list