🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1786

Re: X3J11 Pleasanton meeting summary

#1786
From: Richard A. O'Keefe
Date: Fri, 05 Oct 1990 11:45
59 lines
2637 bytes
In article <1990Oct3.162241.15245@watdragon.waterloo.edu>, ccplumb@spurge.uwaterloo.ca (Colin Plumb) writes:
> In article <1990Oct2.164709.23887@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
> >>	struct foo x;
> >>	struct foo { int i; };
> >>	/* the above is strictly conforming; incomplete-type objects can
> >>	   be defined, so long as by the end of the translation unit the
> >>	   type becomes complete so that storage can then be allocated */

> > Betcha there isn't a compiler on Earth that will accept that today.
> > Everyone I know read the size as being needed at the time of the declaration.

> Taken.  $5.00?  Gcc 1.37.1 (VAX):

I note from The Annotated C++ Reference Manual (S 7.1.1, p 99)
"The name of a class can be used in an extern declaration.  Such
a declaration, however, cannot be used before the class has been
defined.  For example,
	struct S;
	extern S a;		// this is legal [my note]
	extern S f();
	extern void g(S);
	void h()
	    {
		g(a);		// error: S undefined
		f();		// error: S undefined
	    }
"

I have some difficulty with the interpretation, though.
Surely it is possible to produce a fragment of C code where you need
to know the size *before* the end of the translation unit?

	struct Erewhon a, b;

	void do_we_have_to_wait_until_the_end_of_the_unit_for_this_too()
	    {
		a = b;
	    }

	/* megabytes of source code follow ... */

I can see how to handle this; plant calls to a static void __assign_Erewhon()
function, and generate it as soon as you know the size.  Or call a generic
function, picking up the size from a static const, and plant code at the end
to initialise that.  But that could mean the difference between using a
single instruction (movc3, if size < 64k) or calling a procedure (size >).
It isn't quite so clear how to handle

	void surely_this_cannot_wait_so_long()
	    {
		struct Erewhon butler[20];
		...
		samuel(&butler[18]);
	    }

without some sort of runtime support that comes pretty close to being
alloca().
-- 
Fear most of all to be in error.	-- Kierkegaard, quoting Socrates.
Technical Details
Message-ID: <3913@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!goanna!ok
References: <13996@smoke.BRL.MIL> <1990Oct2.164709.23887@zoo.toronto.edu> <1990Oct3.162241.15245@watdragon.waterloo.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!goanna!ok
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.std.c
Subject: Re: X3J11 Pleasanton meeting summary
Summary: cross-reference to C++
Message-ID: <3913@goanna.cs.rmit.oz.au>
Date: 5 Oct 90 11:45:18 GMT
References: <13996@smoke.BRL.MIL> <1990Oct2.164709.23887@zoo.toronto.edu> <1990Oct3.162241.15245@watdragon.waterloo.edu>
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 59