Un-alignment in structures

Chris Torek chris at umcp-cs.UUCP
Sat Mar 23 11:18:47 AEST 1985


Actually, if there is a "good" solution to this, it may not be to add a
modifier keyword, but instead to define a new object which is similar
to a structure, but "compressed" (with access time penalties on some
machines).

This eliminates confusion (or so I claim).  Consider the following:

    unaligned struct foo {
	short f_this;
	char  f_that[2];
    };

    f (foop) unaligned struct foo *foop; {
	...

Is foop a pointer to an unaligned struct foo, or is it an unaligned
pointer to struct foo?  (The proposed "const" modifier has this
problem, by the way.)

    dollop foo {
	short f_this;
	char  f_that[2];
    };

    f (foop) dollop foo *foop; {
	...

Clearly, here "foop" is a pointer to a "dollop" of bytes.

Unfortunately, this doesn't address arrays.  However, I have only ever
wanted unalignment once, and that in a structure.  (Look at the XNS
protocol headers; it requires a 4 byte object that is aligned only on a
2 byte boundary.)  So to generalize from one example (always a
dangerous game!), structure alignment seems more important.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list