Using binary data files

Blair P. Houghton bhoughto at hopi.intel.com
Fri Mar 29 23:17:55 AEST 1991


In article <15086 at ganymede.inmos.co.uk> conor at inmos.co.uk (Conor O'Neill) writes:
>In article <1991Mar21.021023.25615 at athena.mit.edu> scs at 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?"



More information about the Comp.lang.c mailing list