Date: Sun, 16 Feb 1997 13:49:44 +0200 (IST) From: Eli Zaretskii To: Luke Lee cc: djgpp AT delorie DOT com Subject: Re: #pragma pack(1) and ? In-Reply-To: <33041270.30ED@ms2.hinet.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 14 Feb 1997, Luke Lee wrote: > I'm just wondering whether it works or not if : > > #pragma pack(1); > #include 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.