Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl
From: karl@haddock.ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: typedefs and prototypes
Message-ID: <7785@haddock.ima.isc.com>
Date: 21 Sep 88 01:14:16 GMT
References: <7135@bloom-beacon.MIT.EDU> <8543@smoke.ARPA>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Boston
Lines: 20

In article <8543@smoke.ARPA> gwyn@smoke.ARPA (Doug Gwyn) writes:
>	void (*kb_widget1)(int key, void *data) { ... }

That can't be right.  If kb_widget1 is supposed to be a pointer to a function,
then its definition would take an initializer, not a function body.

>In <7135@bloom-beacon.MIT.EDU> tada@athena.mit.edu (Michael Zehr) writes:
>>typedef void (*Keyboard_widget)(int key, void *data);

It looks like what you meant to say was:
	typedef void Keyboard_widget(int key, void *data);
which should clear up the error message.  No, you can't use the typedef when
you actually declare the function, since (as you noted) there's no place to
put the formal parameters.  (There's a note in the dpANS that explicitly
forbids inheriting the parameter list through a typedef.)

Note that the typedef is now "function".  To declare an object of type pointer
to function, you should use "Keyboard_widget *pf;".

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint