Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: net.unix-wizards Subject: Re: Size of struct not same on Ultrix as on v7 Message-ID: <2076@brl-smoke.ARPA> Date: Tue, 25-Mar-86 11:47:06 EST Article-I.D.: brl-smok.2076 Posted: Tue Mar 25 11:47:06 1986 Date-Received: Thu, 27-Mar-86 01:33:28 EST References: <258@cirl.UUCP> Reply-To: gwyn@brl.ARPA Distribution: net Organization: Ballistic Research Lab (BRL) Lines: 26 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.