delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/09/16:17:09

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: <Pine DOT SOL DOT 3 DOT 96 DOT 980709150613 DOT 24539D-100000 AT sol DOT sun DOT csd DOT unb DOT ca>
NNTP-Posting-Host: e016.dynamic.vienna.at.eu.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Destination: Endlisnis <s257m AT unb DOT ca>
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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019