Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!ll-xn!ames!pasteur!ucbvax!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!hpcuhb!hpcllla!hpclisp!mitt From: mitt@hpclisp.HP.COM (Roy Mittendorff) Newsgroups: comp.lang.c Subject: Re: Useful macro...or dangerous?? Message-ID: <660006@hpclisp.HP.COM> Date: 29 Apr 88 23:24:20 GMT References: <221@raunvis.UUCP> Organization: HP NSG/ISD Computer Language Lab Lines: 25 / pablo@polygen.uucp (Pablo Halpern) / 6:04 pm Apr 28, 1988 / > This would work ONLY IF THERE ARE NO HOLES IN THE STRUCTURES BEING COMPARED. > For example, the following would not work on many architectures. > > struct { > char c; > int i; > } x, y; > ... > if (EQ(&x, &y)) > ...; > > On many machines, x.i and y.i will be aligned on word boundaries (i.e., > they must have addresses that are multiples of the word size, typically > 2, 4, or 8). That means that there could be a gap or "hole" of several > bytes between the end of x.c and the beginning of x.i. ... Is there any guarantee that members of structs be stored in any particular order? For example, could c and i may be reversed in some implementations? > Pablo Halpern Roy Mittendorff.