C bit structure
byron at theclarkfamily.name
Thu Mar 19 19:12:01 MDT 2009
On Thu, Mar 19, 2009 at 06:33:48PM -0600, Alec Shaw wrote:
> I want to implement a struct that is 4 bytes in size that has alternate
> bit fields
> similar to the following. The struct below is 12 bytes in size.
> Any suggestions on how create a similar structure of only 4 bytes.
> I want to overlay the structure on a character stream.
Note that this is inherently compiler dependent. That said, here's how
you could define that struct for gcc.
struct __attribute__ ((__packed__)) mystruct
int main(int argc, char* argv)
printf("sizeof(struct mystruct) => %lu\n", sizeof(struct mystruct));
More information about the PLUG