Optimal structure field ordering

Wayne A. Christopher faustus at ic.Berkeley.EDU
Fri Jul 8 18:45:52 AEST 1988


In article <5233 at ihlpf.ATT.COM>, nevin1 at 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



More information about the Comp.lang.c mailing list