Multidimensional Static Array Initialization Follow-up

Tainter tainter at ihlpb.ATT.COM
Tue Aug 23 03:35:25 AEST 1988


In article <13060 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> In article <2682 at jpl-devvax.JPL.NASA.GOV> timg at jpl-devvax.JPL.NASA.GOV
>(Tim Graham) writes:
>>For example ...
>>  int foo[][4] = { { 1, 2,  3,  4  }, { 5, 8          }, { 9, 10, 12     } };
>>... the uninitialized elements in the 3x4 array are filled with zeros.  Is
>>it really that much harder for it to be possible to implement
>>  int foo[][] = { { 1, 2,  3,  4  }, { 5, 8          }, { 9, 10, 12     } };

> Yes.  Consider the situation from the compiler's point of view,
> and in particular, the case where the first row is not the longest:

> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
> Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris


It isn't just an issue of the initializer.  Consider code referencing the
above entity foo.  As long as only one dimension is unknown C can generate
code to manipulate the structure without requiring patching at link time.
Note:  Defering the resolution of this type of symbol would probably
complicate using an assembler as a back end for the c ompiler.

--j.a.tainter
ihlpb!tainter



More information about the Comp.lang.c mailing list