Useful macro...or dangerous??
Roy Mittendorff
mitt at hpclisp.HP.COM
Sat Apr 30 09:24:20 AEST 1988
/ pablo at 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.
More information about the Comp.lang.c
mailing list