I have an AVR program which stores a set (usually less than 8) bit flags in a static status variable (which is contained inside a struct holding various other state fields of the module).
if it more or less efficient to do it like this:
#define STATUS_ENABLED 0x01
struct DeviceState {
uint8_t status;
}
static struct DeviceState myState;
//and somewhere in the program...
myState.status |= STATUS_ENABLED;
Or do it with a packed bitfield:
struct DeviceState {
uint8_t enabled : 1;
}
static struct DeviceState myState;
//and somewhere in the program...
myState.enabled = 1; // could use TRUE/FALSE if defined