cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/16/07:09:16

Date: Sun, 16 Feb 1997 13:49:44 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Luke Lee <comforth AT ms2 DOT hinet DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: #pragma pack(1) and <grx20.h> ?
In-Reply-To: <33041270.30ED@ms2.hinet.net>
Message-ID: <Pine.SUN.3.91.970216134502.15715G-100000@is>
MIME-Version: 1.0

On Fri, 14 Feb 1997, Luke Lee wrote:

>     I'm just wondering whether it works or not if :
> 
>     #pragma pack(1);
>     #include <grx20.h>

Don't do that!  This will change the offsets of some struct members, and 
your programs which use GRX will stop working, because the library wasn't 
compiled with packed structs.

>  * With #pragma pack(1); 
>      sizeof(cprec+cpos)=6  
>  * Without #pragma pack(1);
>      sizeof(cprec+cpos)=8

That is exactly the effect pragma pack should have.

>  Sorry if this is a dumb question... :-P
>  since this problem is critical to my program ... Thanks !

Why is it so critical?  You shouldn't have any problems using the 
original unpacked struct, even if you read/write them.  Just use sizeof 
operator to read the struct instead calculating the sum of sizes of all 
the members.  The only problem that you might have is sharing such files 
with other compilers.  See section 22.9 of the DJGPP FAQ list for more on 
this.

- Raw text -


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