Size of struct not same on Ultrix as on v7
Dave Steffens
das at cirl.UUCP
Tue Mar 25 07:00:32 AEST 1986
Background: We would like to generate data files on a PDP11/34 (running v7)
and ship them to our uVAX II (running Ultrix) for further processing.
The data files are created by writing out records built up from struct's.
The program which processes the files expects to be able to read records
using the same structure definitions which were used to create them.
We are thus in the process of porting programs written on v7 to Ultrix.
One major problem has been that struct's appear not to be the same size
when compiled on Ultrix as they are when compiled on v7.
This appears to be true for 4.2bsd as well.
What seems to be happening is that under Ultrix (and 4.2bsd) the compiled
length of every struct is rounded up to a multiple of the length of the
longest element in it. Thus, struct's containing neither ints nor longs are
*always* multiples of 2 bytes whereas struct's containing either ints or longs
are *always* multiples of 4 bytes.
The bottom line is that files written on v7 can be processed correctly on v7
and files written on Ultrix can be processed correctly on Ultrix
but files written on v7 can't be processed correctly on Ultrix because
the *padded* struct's on Ultrix do not match the record size as written on v7.
Why does the Ultrix (4.2bsd) C compiler insist on padding struct's?
Is there any fix (other than hard-wiring the record size into every program)?
--
{harvard,mit-eddie,think}!eplunix!earvax!das David Allan Steffens
243 Charles St., Boston, MA 02114 Eaton-Peabody Laboratory
(617) 523-7900 x2748 Mass. Eye & Ear Infirmary
More information about the Comp.unix.wizards
mailing list