automatic aggregate initialization

Dave Decot decot at hpda.UUCP
Sat Jun 1 02:52:01 AEST 1985


> its an implementation nightmare to have to init structures/arrays/unions
> Remember automatic means that this stuff is on the stack, and your subroutine
> will have to spend time doing the init (which should have just been static)
> I agree it should be allowed but I won't use it.
> 
> Hedley Rainnie.

The language already allows you to declare automatic structures/arrays/unions.
They do go on the stack.  You probably use them whenever you call stat(2).

To implement automatic initialization, pretend it's static, and generate the
value somewhere at the beginning.  Whenever the function or block is entered,
just copy the block of memory into the stack where it's supposed to be.
Simple.  This is an easy way to do aggregate constants, too, but nobody
seems to like that idea.

Dave Decot  /  Hewlett-Packard Company  /  Data Systems Division
decvax!ucbvax!hpda!decot



More information about the Comp.lang.c mailing list