Article View: comp.std.c
Article #2660function declarators
From: Daniel Edelson
Date: Mon, 01 Apr 1991 23:36
Date: Mon, 01 Apr 1991 23:36
29 lines
1266 bytes
1266 bytes
I have tried unsuccessfully to find an unambiguous statement....
in the standard that allows or prohibits the following cases:
1) a function declaration that defines a new
type in the return type, and,
2) a function declaration that defines a new
type in a parameter
For example:
/*
* The return type of foo() defines a new type, struct S
*/
struct S { int a; } foo(void) { }
/*
* The parameter of bar() defines a new type, struct T
*/
void bar(struct T { int b; } p) { }
The function ``bar'' is not particularly
useful because the only type-safe calls to it can be
recursive calls, since ``struct T'' has block scope.
Are these strictly conformant ANSI C code?
If so, in the above example, must ``struct S'' be given
file scope?
Thanks,
Daniel Edelson
Technical Details
Message-ID:
<14000@darkstar.ucsc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!apple!agate!darkstar!terra.ucsc.edu!danielShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!apple!agate!darkstar!terra.ucsc.edu!daniel From: daniel@terra.ucsc.edu (Daniel Edelson) Newsgroups: comp.std.c Subject: function declarators Message-ID: <14000@darkstar.ucsc.edu> Date: 1 Apr 91 23:36:47 GMT Sender: usenet@darkstar.ucsc.edu Reply-To: daniel@terra.ucsc.edu (Daniel Edelson) Organization: University of California, Santa Cruz Lines: 29