🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2357

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

#2357
From: Henry Spencer
Date: Mon, 04 Feb 1991 18:54
14 lines
1233 bytes
In article <1991Feb4.053613.3758@watmath.waterloo.edu> datangua@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@zoo.toronto.edu   utzoo!henry
Technical Details
Message-ID: <1991Feb4.185409.7034@zoo.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!henry
References: <1212@tredysvr.Tredydev.Unisys.COM> <1991Jan29.210100.8105@zoo.toronto.edu> <22642@netcom.UUCP> <1991Feb3.000128.15980@zoo.toronto.edu> <1991Feb4.053613.3758@watmath.waterloo.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: typedefing functions (Re: Is typedef char BUFFER[20] legal?)
Message-ID: <1991Feb4.185409.7034@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <1212@tredysvr.Tredydev.Unisys.COM> <1991Jan29.210100.8105@zoo.toronto.edu> <22642@netcom.UUCP> <1991Feb3.000128.15980@zoo.toronto.edu> <1991Feb4.053613.3758@watmath.waterloo.edu>
Date: Mon, 4 Feb 1991 18:54:09 GMT