🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1002

type definitions and scopes

#1002
From: Daniel Edelson
Date: Mon, 01 Apr 1991 23:30
29 lines
1279 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: <13998@darkstar.ucsc.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!agate!darkstar!terra.ucsc.edu!daniel

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!agate!darkstar!terra.ucsc.edu!daniel
From: daniel@terra.ucsc.edu (Daniel Edelson)
Newsgroups: comp.std.c++
Subject: type definitions and scopes
Keywords: function return type, declarators
Message-ID: <13998@darkstar.ucsc.edu>
Date: 1 Apr 91 23:30:41 GMT
Sender: usenet@darkstar.ucsc.edu
Reply-To: daniel@terra.ucsc.edu (Daniel Edelson)
Organization: University of California, Santa Cruz
Lines: 29