delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/08/07:25:20

Date: Tue, 8 Apr 1997 14:12:30 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Mark T Logan <fwec AT juno DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Problem with Packed structs
In-Reply-To: <19970407.211716.7135.3.fwec@juno.com>
Message-ID: <Pine.SUN.3.91.970408141204.1046S-100000@is>
MIME-Version: 1.0

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019