I was reading through the documentation of GNU/GCC and I stopped at the description of __attribute__ ((packed))
.
It says:
packed
The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute.
Here is a structure in which the field x is packed, so that it immediately follows a:
struct foo
{
char a;
int x[2] __attribute__ ((packed));
};
I wonder how this attribute works exactly and whether this code:
struct foo
{
char a:1 __attribute__ ((packed));
};
would create a 1-bit structure instead of 1-byte.