Mail Archives: djgpp/1997/04/12/19:26:40
In article <Pine DOT SUN DOT 3 DOT 91 DOT 970408141204 DOT 1046S-100000 AT is>, Eli Zaretskii
<eliz AT is DOT elta DOT co DOT il> writes
>This is a very bad idea, IMHO. You should never share binary files
>between different compilers. The precise way the compiler packs
>struct members is very implementation-dependent and can change without
>notice in future versions of the same compiler. So even if you find a
>way to read in a file that was written by another compiler, your
>program will break if, for example, GCC will align the structs
>differently in some future version, e.g., to make its support for
>Pentium Pro better.
>
>I would suggest to write the struct members one by one as text. The
>other program will then have to read them in member by member also.
>This is a bit harder to program, but a lot more robust.
I think you're going a little too far here! Reading and writing binary
values is faster and uses less space. It also avoids the problems that
can happen with using files in text mode (I learnt long ago not to open
*any* files in text mode, I like fseek to work on any compiler for
instance!)
It is vitally important to read and write fields explicitly, and *never*
load images into anything larger than a character (to avoid endian
problems)
---
Paul Shirley: shuffle chocolat before foobar for my real email address
- Raw text -