[comp.lang.c] Compile-time initialization

brucee@runxtsa.runx.oz.au (Bruce Evans) (08/11/90)

In article <17300@haddock.ima.isc.com> karl@kelp.ima.isc.com (Karl Heuer) writes:
>I recently proposed an extension to allow labeled initializers:
>	#define FILE_FOOTER_ERROR  1
>	#define DRAW_FOOTER_ERROR  2
>	char errortext[3][40] = {
>	    0:                 "234567890123456789012345678901234567890",
>	    DRAW_FOOTER_ERROR: "Draw footer error",
>	    FILE_FOOTER_ERROR: "File footer error",
>	};
>This might make it into gcc (and maybe from there into C-2001?).

What about allowing initialization by assignment?

	char errortext[3][40];
	...
	errortext[0] = "234567890123456789012345678901234567890";
	...
	errortext[DRAW_FOOTER_ERROR = "Draw footer error";
	...
	errortext[FILE_FOOTER_ERROR = "File footer error";

And similarly for structures.
-- 
Bruce Evans
Internet: brucee@runxtsa.runx.oz.au    UUCP: uunet!runxtsa.runx.oz.au!brucee
(My other address (evans@ditsyda.oz.au) no longer works)

henry@zoo.toronto.edu (Henry Spencer) (08/12/90)

In article <2157@runxtsa.runx.oz.au> brucee@runxtsa.runx.oz.au (Bruce Evans) writes:
>What about allowing initialization by assignment?
>
>	char errortext[3][40];
>	...
>	errortext[0] = "234567890123456789012345678901234567890";

The idea has merit, but *please* find a different syntax.  It is already
a royal pain to parse C declarations because you can't tell what's going
on until the middle of the declaration.  I like the labels inside an
initializer list better.
-- 
It is not possible to both understand  | Henry Spencer at U of Toronto Zoology
and appreciate Intel CPUs. -D.Wolfskill|  henry@zoo.toronto.edu   utzoo!henry