struct element orderin vs. align

jim at ISM780B.UUCP jim at ISM780B.UUCP
Mon Jan 14 16:47:07 AEST 1985


>Sigh,
>        until you give me a subclass mechanism that ensures that the
>representation of two data types share a common prefix, I'll rely on this
>compiler hack.

You already have it:

struct {
	common part;
	union {
		distinct part1;
		distinct part2;
		...
	};
};
The distinct parts can of course be structures.
This is the only guaranteed portable way to do this.

-- Jim Balter, INTERACTIVE Systems (ima!jim)



More information about the Comp.lang.c mailing list