Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!cornell!uw-beaver!milton!ogicse!intelhf!ichips!iwarp.intel.com!inews!hopi!bhoughto From: bhoughto@hopi.intel.com (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: Using binary data files Message-ID: <3557@inews.intel.com> Date: 29 Mar 91 13:17:55 GMT Article-I.D.: inews.3557 References: <1991Mar20.224317.1265@grebyn.com> <1991Mar21.021023.25615@athena.mit.edu> <15086@ganymede.inmos.co.uk> Sender: news@inews.intel.com Organization: Intel Corp, Chandler, AZ Lines: 27 In article <15086@ganymede.inmos.co.uk> conor@inmos.co.uk (Conor O'Neill) writes: >In article <1991Mar21.021023.25615@athena.mit.edu> scs@adam.mit.edu writes: >Binary data files are fine, AS LONG AS YOU SPECIFY THE FORMAT, >The problem is that many people `document' the format by supplying a >struct definition, and, of course, struct definitions are most definitely >_not_ portable. >A binary file specified as something like "Each 'record' is a list of 10 >32-bit twos-complement integers, each stored least significant byte first" >is perfectly portable. On some machines, they could be read directly into But, of course, if you're the person who _should_ be doing the port, you'll be familiar with both architectures, and will know how to translate one struct to the other, bit-by-bit, if necessary. The rule to follow about binary files is: if it wasn't written on this machine under this OS, don't expect it to work, just try it and see if it does. It's almost guaranteed to be a problem needing hacking, and expecting that expense will do much more for your stressor-count than anyone's bitwise struct definitions. --Blair "I need to dig a posthole and I don't want to reinvent the wheel, so could someone please email me the plans for one? In ANSI format?"