typedefing functions (Re: Is typedef char BUFFER[20] legal?)

Henry Spencer henry at zoo.toronto.edu
Tue Feb 5 10:44:41 AEST 1991


In article <ENAG.91Feb4192806 at holmenkollen.ifi.uio.no> enag at ifi.uio.no (Erik Naggum) writes:
>you can say
>	typedef int f (int a, char *b);
>and later say
>	f foo, bar, zot;
>and
>	f *functab[3] = { foo, bar, zot, };

Correct so far.

>The functions would be declared
>	f foo
>	{ ... }

Nope, wrong.  The function definition itself must contain an explicit
function declarator; it cannot inherit its "functionness" from a typedef.
See Constraints in 3.7.1.
-- 
"Maybe we should tell the truth?"      | Henry Spencer at U of Toronto Zoology
"Surely we aren't that desperate yet." |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.std.c mailing list