Mail Archives: djgpp/1997/02/16/07:09:16
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 -