Portablity using structures and malloc - Help

Frank Adams franka at mmintl.UUCP
Tue Jul 30 06:21:56 AEST 1985


In article <5181 at elsie.UUCP> ado at elsie.UUCP (Arthur David Olson) writes:
>In article <257 at bocklin.UUCP>, wendt at bocklin.UUCP writes:
>> An easy way to determine alignment requirements is to take the size
>> of a structure containing one character.  Odd-length structures are
>> invariably rounded up to convenient units by the compiler.
>
>Or, preferably,
>	#define ALIGNMENT (sizeof (struct { char :1;}))
>which avoids having to make up a name for a structure element.

This also has the advantage of working properly on a hypothetical machine
where alignment on a character boundary is not required.



More information about the Comp.unix mailing list