typedefing functions (Re: Is typedef char BUFFER[20] legal?)
David Tanguay
datangua at watmath.waterloo.edu
Mon Feb 4 16:36:13 AEST 1991
In article <1991Feb3.000128.15980 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
>Nope, syntax error. Typedef is semantically a special case, but not
>syntactically: a type declaration looks *exactly* like a declaration
>of an ordinary variable except for that funny word "typedef" on the
>front.
Our compiler had a neat bug with this. It would accept, e.g.,
typedef int f( int a ) { return a+1; }
"f" would be a type thereafter in that file, but it was also created as
an external visible only outside that file. Syntacticly typedef is the
same as static or extern.
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.
--
David Tanguay Software Development Group, University of Waterloo
More information about the Comp.lang.c
mailing list