RISC Machine Data Structure Word Alignment Problems?

Doug Toppin X2075 toppin at melpar.UUCP
Sat Jan 20 10:46:21 AEST 1990


We are using the SUN 4/260 which is a RISC architecture machine.
We are having trouble with data alignment in our data structures.
We have to communicate with external devices that require data structures
such as the following:
	struct
	{
		long  a;
		short b;
		long  c;
	};
When we compile and link something referencing this structure the
data produced appears to have had each element word boundary aligned
so that what results appears to be as follows:
	struct
	{
		long  a;
		short b;
		short pad; <==== this was inserted by cc to align next thing
		long  c;
	};
This means that we lose the benefit of data abstraction and have
to create our own output without using structures.
We have not been able to find any Sun-4 cc option that eliminates
this problem. We cannot use the 'compile as Sun-3' option.
Please let us know if you know of a built-in way around this.
thanks
Doug Toppin
uunet!melpar!toppin



More information about the Comp.lang.c mailing list