Possible Duplicate:
What does 'unsigned temp:3' means
This is C code sample of a reference page.
signed int _exponent:8;
What's the meaning of the colon before '8' and '8' itself?
Possible Duplicate:
What does 'unsigned temp:3' means
This is C code sample of a reference page.
signed int _exponent:8;
What's the meaning of the colon before '8' and '8' itself?
It's a bitfield. It means that the system will only use 8 bits for your integer.
It's a bitfield, an obscure and misguided feature of structures. That should be enough for you to lookup the information you need to know to deal with bitfields in other people's code. As for your own code, never use bitfields.
Edit: As requesed by Zack, bitfields have significant disadvantages versus performing your own bit arithmetic, and no advantages. Here are some of them:
For single-bit flags, using your own bit arithmetic instead of bitfields is a complete no-brainer. For larger values you need to pack, if it's too painful to write out all the bit arithmetic all over the place, write some simple macros.
It is a bitfield specification.
It means _exponent
takes only 8
bits out of the signed int
which typically takes more than 8
bits. Typically, bit-fields are used with unsigned types.
IIRC, compiler would warn if a something that does not fit into 8-bits is written into _exponent
.