typedefs and prototypes

Doug Gwyn gwyn at smoke.ARPA
Wed Sep 21 06:41:00 AEST 1988


In article <7135 at bloom-beacon.MIT.EDU> tada at athena.mit.edu (Michael Zehr) writes:
>typedef void (*Keyboard_widget)(int key, void *data);
>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???

Use exactly the syntax of the typedef, minus "typedef", with the
type name replaced by the identifier.  I.e.
	void (*kb_widget1)(int key, void *data) { ... }

>Keyboard_widget kb_widget1  /* where do the formal parameters go??? */
>{...}

This one is a mystery to me too.  The compilers I've tried this on
are unhappy no matter how I try to use the typedef in defining the
function.  Fortunately the explicit definition is completely
compatible, but it would be nice if the typedef method worked.



More information about the Comp.lang.c mailing list