donn (09/09/82)
The only complete way to solve the problem of portability of binary data gen- erated by C programs is to create and enforce restrictions on the alignment of the various data types, and the format of long integers and floating point numbers. The standard would have to be that of the most restrictive/bizarre machine. I can imagine people writing horribly distorted compilers that use data formats and alignments completely unsuited to the machine they are based on... No one in their right mind would ever do such a thing. The next least ridiculous thing that can be done, short of writing out only clumsy voluminous ASCII data, is to find a reasonable arrangement that is not too gruesome and that can be handled by at least a large subset of the avail- able machines, or of the machines of a given family. At UCSD this has pro- duced two varieties of compiler: a mildly tweaked pcc for the VAX which does 16-bit alignment of 32-bit quantities (but no adjustment of longs); and a severely abused Ritchie compiler for the PDP which does VAX longs adjustment (and may soon with a little tweaking do 32-bit alignments). The latter pro- duces systems which boot off of VAX filesystems on dual-ported disk drives and controllers. Since our applications involve lots of binary files and we expect to be able to make them on both VAXen and PDPs, such portability is indispensable. I was mildly surprised to find that it hadn't been attempted before... Donn Seeley UCSD Chemistry Dept. RRCF ucbvax!sdcsvax!sdchema!donn