Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ic.Berkeley.EDU!faustus From: faustus@ic.Berkeley.EDU (Wayne A. Christopher) Newsgroups: comp.lang.c Subject: Re: Optimal structure field ordering Message-ID: <4347@pasteur.Berkeley.Edu> Date: 8 Jul 88 08:45:52 GMT References: <5233@ihlpf.ATT.COM> <163@navtech.uucp> <806@garth.UUCP> <254@obie.UUCP> <3459@rpp386.UUCP> Sender: news@pasteur.Berkeley.Edu Lines: 26 In article <5233@ihlpf.ATT.COM>, nevin1@ihlpf.ATT.COM (00704a-Liber) writes: > >it could be serious for any language to not specify how it rearranges > >structures. it could make it impossible for separate compilation to > >work, period. > > Not quite true. As long as the compiler internally arranges the fields in > a structure the same way, no problems occur. (1) What if I write a binary data file (with structures), re-compile my program (not having realized that somebody installed the new compiler with structure optimization) and then try to read it back in? (2) The system libraries have been compiled with stupid pcc, which doesn't do structure re-ordering. My compiler does re-ordering, so when I call a library function that returns a standard structure (like struct passwd), I'm screwed. (3) For that matter, what if I want to compile half my code with one compiler and half with another? (This isn't silly -- I've written libraries that other people use, and want to use saber with. Saber doesn't understand gcc's symbol tables, but I would rather give up saber than gcc. So I compile my library with pcc and the rest of my program with gcc, so I can get good quality code for part of the program and the other people can get saber.) Wayne