C special syntax (adding ':') when defining a structure

Possible duplicate:
What it does: do in the structure declaration after the member

I would like to ask why the symbol was added in this structure::

 typedef union A { struct { ubyte B:4; } } struct_a; 

Thank you in advance;

+4
source share
3 answers

It declares a bit field with 4 bits.

+2
source

:4 places a 4-bit constraint on the variable. See Section 6.9 of Kernighan and Richie.

+4
source

He called the field a bit. In this case, he says that size B is 4 bits.

+3
source

All Articles