Size of struct not same on Ultrix as on v7
Doug Gwyn
gwyn at brl-smoke.ARPA
Wed Mar 26 02:47:06 AEST 1986
The VAX PCC tries to align data more stringently than necessary
(which would be on arbitrary byte boundaries) because its implementor
was trying to accommodate the way the VAX-11/780 memory system
operated, in order to speed up memory references somewhat.
To write binary data on a PDP-11 for export to a VAX-11:
struct {
char c1;
char pad1[3]; /* alignment padding */
float f;
long l;
short s;
char pad2[2]; /* alignment padding */
double d;
char c2;
char pad3[3]; /* alignment padding */
} record;
In other words, include sufficient padding in your struct so
that the compilers on both systems will not add any more padding.
Also be aware that you have to swap the halves of a (long) when
moving it between a PDP-11 and a VAX-11. Finally, if you have
to move the data to another architecture, some or all of the
binary information (particularly floating-point) would have to
be interpreted for the target. This is why it is recommended
that inter-machine transfer of data be done in character format
when feasible.
More information about the Comp.unix.wizards
mailing list