Possible Duplicate:
What does 'unsigned temp:3' mean?
please what does this notation mean
int a:16;
I found it is code like this and it does compile.
struct name { int a:16; }
Possible Duplicate:
What does 'unsigned temp:3' mean?
please what does this notation mean
int a:16;
I found it is code like this and it does compile.
struct name { int a:16; }
This is a bitfield.
This particular bitfield doesn't make much sense as you just could use a 16-bit type and you're wasting some space as the bitfield is padded to the size of
int
.Usually, you are using it for structures that contain elements of bit size:
It means
a
is defined as 16-bit memory space. The remaining bits (16 bits) fromint
can be used to defined another variable, sayb
, like this:So if
int
is 32-bit (4 bytes), then the memory of oneint
is divided into two variablesa
andb
.PS: I'm assuming
sizeof(int)
= 4 bytes, and 1 byte = 8 bitsIt's a bitfield.
I've never seen a 16 bit bitfield; usually that's a short.
http://www.cs.cf.ac.uk/Dave/C/node13.html