From: sparhawk AT eunet DOT at (Gerhard Gruber) Newsgroups: comp.os.msdos.djgpp Subject: Re: packed Bit-Fields Date: Thu, 09 Jul 1998 19:54:08 GMT Organization: Customer of EUnet Austria Lines: 28 Message-ID: <35ad1e6b.18964698@news.Austria.EU.net> References: NNTP-Posting-Host: e016.dynamic.vienna.at.eu.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Destination: Endlisnis From: Gruber Gerhard Group: comp.os.msdos.djgpp Date: Thu, 9 Jul 1998 15:09:53 -0300: > If I have something like: >struct { > int z; > char m; > int a:3, b:7, c:10, d:10, e:2; > }; > > Where should I put "__attribute__((packed))" to make sure there is >no 'slack-space' in that struct (especially between 'm' & 'a')? Do I have >to put it after each variable? {a,b,c,d & e} I'd suggest that you use char for bitfields instead. This way the compiler creates exactly the number of bytes it needs for the bits. Even when the number of bits are bigger then a byte. -- Bye, Gerhard email: sparhawk AT eunet DOT at g DOT gruber AT sis DOT co DOT at Spelling corrections are appreciated.