Path: utzoo!utgpu!water!watmath!clyde!att!ihlpb!tainter From: tainter@ihlpb.ATT.COM (Tainter) Newsgroups: comp.lang.c Subject: Re: Multidimensional Static Array Initialization Follow-up Message-ID: <8596@ihlpb.ATT.COM> Date: 24 Aug 88 04:26:27 GMT References: <2682@jpl-devvax.JPL.NASA.GOV> <13060@mimsy.UUCP> <8584@ihlpb.ATT.COM> <13149@mimsy.UUCP> Reply-To: tainter@ihlpb.UUCP (55521-Tainter,J.A.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 30 In article <13149@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >[questions and answers about when array sizes can be elided deleted] >In article <8584@ihlpb.ATT.COM> tainter@ihlpb.ATT.COM (Tainter) writes: >>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. >The question was about initialised arrays---specifically, about the >cases where the compiler is able to deduce the dimensions. Hence >*none* of the dimensions are unknown; they are merely left up to the >compiler to count. Which is all well and good for the module allocating the object and initializing it, but what about other modules declaring it extern? Those are the ones that end up needing the patching at link time. Thus for security in the code you should explicitly declare the dimension in both places (extern declaration and the definition) using a macro, included into both files. Therefore, to encourage this, the language should, and does require all lower dimensions. Or better yet use a typedef! Of additional interest, what does one do with function parameters if the lesser dimensions are not explicitly declared? Again one wants to encourage use of a common dimension definition. >In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) --j.a.tainter ihlpb!tainter