Path: utzoo!attcan!uunet!husc6!uwvax!rutgers!rochester!cornell!blandy From: blandy@awamore.cs.cornell.edu (Jim Blandy) Newsgroups: comp.lang.c Subject: Re: Optimal structure field ordering Message-ID: <18630@cornell.UUCP> Date: 27 Jun 88 13:31:13 GMT References: <163@navtech.uucp> <2775@ttrdc.UUCP> <164@navtech.uucp> Sender: nobody@cornell.UUCP Reply-To: blandy@cs.cornell.edu (Jim Blandy) Organization: Cornell Univ. CS Dept, Ithaca NY Lines: 27 In article <164@navtech.uucp> mark@navtech.UUCP (Mark Stevans) writes: >Some responder pointed out correctly that there is no guarantee in the C >language that the compiler will preserve your field ordering ... Hmm. K&R v1, p. 196 (section 8.5 in the reference manual) (ooh, quote K&R, baby! It's SO SEXY!) "Within a structure, the objects declared have addresses which increase as their declarations are read left-to-right." (ooh, that was so good! Now be wishy-washy!) Now I could be wrong, but that looks like a pretty clear statement on how C orders structures... I like the fact that C won't mess with your arrangement - 1) If you want to pack for space, you can. 2) If you need to conform to somebody else's format (in files or system calls or functions written in other languages), you can. I think letting the language decide for you which one was important would be a mistake. Using any high-level language will take some control out of your hands, but C does very little of this; I like that. -- Jim Blandy - blandy@crnlcs.bitnet "insects were insects when man was just a burbling whatsit." - archie