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

Henry Spencer henry at zoo.toronto.edu
Tue Feb 5 05:54:09 AEST 1991


In article <1991Feb4.053613.3758 at watmath.waterloo.edu> datangua at watmath.waterloo.edu (David Tanguay) writes:
>	typedef int f( int a ) { return a+1; }
>
>Is the above typedef valid in ANSI-C (as a typedef)? It's not a valid
>function declaration (has to be static or extern), but I can't recall
>anything making it an invalid typedef.

It's not a valid typedef because that `{ return a+1; }' cannot appear in
a declaration of any kind.  The presence of the function body makes this
a function definition, not a declaration, and `typedef' is not legal in
a function definition.
-- 
"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