function declarators

Daniel Edelson daniel at terra.ucsc.edu
Tue Apr 2 09:36:47 AEST 1991


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



More information about the Comp.std.c mailing list