When writing network protocols or de-marshalling binary data it's common to want to know which bits are set in a byte. You might do
a & 4 == 4
to test the 3rd bit is set, how would you do this with 'regular programming'?
struct header __atribute__((packed)) {
unsigned int highnibble : 4;
unsigned int flag_foo : 1;
unsigned int flag_bar : 1;
unsigned int flag_baz : 1;
unsigned int flag_qux : 1;
}
if (((header)value).flag_bar) {