Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site cirl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!cirl!das From: das@cirl.UUCP (Dave Steffens) Newsgroups: net.unix-wizards Subject: Size of struct not same on Ultrix as on v7 Message-ID: <258@cirl.UUCP> Date: Mon, 24-Mar-86 16:00:32 EST Article-I.D.: cirl.258 Posted: Mon Mar 24 16:00:32 1986 Date-Received: Wed, 26-Mar-86 04:34:14 EST Distribution: net Organization: Eaton-Peabody, Mass. Eye & Ear Lines: 28 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