Can bit-fields only be fields of a structure/union, never “normal”, “stand-alone” variables?
Yes, that's right.
but why it is so...?
n with bit-fields we can only use char and int?
The type of a bit field can be any integral (that's bool, char, int, etc) or enum type.
thanks cubbi for reply.

but in your reference link also bit field use with structure.

why we can not use it “stand-alone”?
What would that accomplish?

A bit field that is not part of a struct would presumably occupy a full word so why not just use an integral type?

By forcing bit fields to be members of a struct, it becomes clear how the bits are packed.

Topic archived. No new replies allowed.