From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: packed data structures? Date: Sun, 06 Oct 1996 23:56:58 -0700 Organization: Three pounds of chaos and a pinch of salt Lines: 31 Message-ID: <3258A9B9.21EF@cs.com> References: <52nl1a$kqv AT news2 DOT cnct DOT com> <32574F0D DOT 215B AT lux DOT latrobe DOT edu DOT au> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: 204.252.76.241 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Natasha and Don To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Natasha and Don wrote: > > John Panettiere wrote: > > > > Hello, all. > > > > ... realized that djgpp wasn't packing the data structures - so I browsed > > the info files and found "__attribute__((packed))", which seemed to be > > the answer I was looking for. > > Hmm I suspect that your problem is that you are using C++, > __attribute__ ((packed)) only seems to work for C. I have exactly > the same problem myself and am thinking of using bitfields (barf)! > > Does any one else have any ideas? *sigh*. If only more people would read the FAQ. There is a bug in the gcc compiler that makes it not pack structures correctly in C++. You have to surround the structure you want packed with #pragma pack(1) ... #pragma pack(). The FAQ (v2/faq201b.zip) talks about this exact problem in section 22.10. Eli, DJ? Is there a fixed version of gcc in v2.01? A lot of people would be curious to know. :) -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com | | Plan: To find ANYONE willing to | http://www.cs.com/fighteer | | play Descent 2 on DWANGO! | Tagline: | ---------------------------------------------------------------------