drw@cullvax.UUCP (Dale Worley) (08/07/87)
rbutterworth@orchid.waterloo.edu (Ray Butterworth) writes: > In article <1429@cullvax.UUCP>, drw@cullvax.UUCP (Dale Worley) writes: > > arnold@emory.uucp (Arnold D. Robbins {EUCC}) writes: > > > extern struct pte Mbmap[]; /* page tables to map mbutl */ > > Well, reading 3.5.2.2 and 3.5.3.2 of the draft suggests that this > > module doesn't need to know the size of Mbmap at all (unless you > > sizeof it or something), and so the size of struct pte doesn't need to > > be known, and so struct pte need not be fully declared. > > [Ray notes this leads to strange phenomena] I'm definitely wrong. The compiler doesn't need to know the size of Mbmap, but is surely needs to know the size of a 'struct pte' in order to generate the indexing code! (Similarly if you say 'extern struct pte *Mbmap'.) Thus, 'struct pte' has to be declared fully. But, precisely *when* does 'struct pte' have to be declared by? The time the declaration is encountered, or the first time Mbmap is subscripted? The Draft doesn't make it clear. In fact, the Draft says (page 53, line 7 and footonote 37): An incomplete structure or union specifier of the form struct-or-union identifier declares a tag that may be used only when the size of an object of the specified type is not needed.(37) 37: For example, [...] when a pointer to [...] a structure or union is being declared. [...] But, since ANSI C is designed to support systems where pointers have differing sizes depending on what is pointed to, declaring a pointer to a structure *always* requires the full definition of the structure to be known (as Ray points out). This footnote is probably wrong. Dale -- Dale Worley Cullinet Software ARPA: cullvax!drw@eddie.mit.edu UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw OS/2: Yesterday's software tomorrow Nuclear war? There goes my career!