Date: Tue, 8 Apr 1997 14:12:30 +0300 (IDT) From: Eli Zaretskii To: Mark T Logan cc: djgpp AT delorie DOT com Subject: Re: Problem with Packed structs In-Reply-To: <19970407.211716.7135.3.fwec@juno.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Mon, 7 Apr 1997, Mark T Logan wrote: > Since DJGPP packs structs, the structs are of a different size than you > might find when using a 16 bit compiler. You can't read the file in > unless the structs that you are reading into are the same as the > structs that were written. > > What if I want to read a file I make with say, a Visual Basic 16 bit > program? 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. Note that the DJGPP FAQ list explains more about this issue in section 22.9.