From: pavenis AT lanet DOT lv To: Waldemar Schultz , djgpp AT delorie DOT com Date: Wed, 18 Apr 2001 15:14:59 +0300 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: MINGW vs DJGPP Message-ID: <3ADDAF73.24905.59B576@localhost> In-reply-to: <3ADD7C03.ACF8938C@ma.tum.de> X-mailer: Pegasus Mail for Win32 (v3.12c) Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 18 Apr 2001, at 13:35, Waldemar Schultz wrote: > Eli Zaretskii schrieb: > > > > On Wed, 18 Apr 2001, Waldemar Schultz wrote: > > > > > BTW I couldn't resist to try the `-fpack-struct' switch Eli mentioned: > > > now MINGW reports the size of the struct being _97_ vs _88_ without the > > > switch. > > > > That sounds like a bug in MinGW. What version of GCC is that? Is the > > version of GCC you use for DJGPP compilation different? > > MINGW>gcc -v > Reading specs from > E:\MINGW\BIN\..\lib\gcc-lib\i386-mingw32msvc\2.95.2\specs > gcc version 2.95.2 19991024 (release) > > DJGPP>gcc -v > Reading specs from e:/djgpp/lib/gcc-lib/djgpp/2.952/specs > gcc version 2.95.2 19991024 (release) > -fpack-struct seems to be broken with gcc-2.95.X for DJGPP. I tested following short test program: #include struct foo { char foo_1; short foo_2; long foo_3; double foo_4; } ; foo x; #define _offset_(a) (((char *) &x.a) - ((char *) &x.foo_1)) int main (void) { std::cout << sizeof(foo) << " (" << _offset_(foo_1) << " " << _offset_(foo_2) << " " << _offset_(foo_3) << " " << _offset_(foo_4) << ")\n"; } Here is output I got: gcc-2.95.3 for DJGPP: 16 (0 2 4 8) gcc-2.95.2 DJGPP to MINGW cross-compiler: 15 (0 1 3 7) gcc-3.0 20010314 (prerelease) for DJGPP: 15 (0 1 3 7) I didn't test other versions. My suggestion: put #pragma pack() before definition of structure and #pragma pack(1) after it. I'm using it already for a long time without problems (except early prereleases of gcc-2.95 where #pragma pack() was buggy). This is better way than -fpack-struct as it's only packs structures one wants to pack. Andris