Well now, this is puzzling. Case 1 uses a bit field:
struct myByte {
int foo : 1;
};
volatile myByte bar;
void setup ()
{
Serial.begin (115200);
bar.foo = 1;
Serial.println (bar.foo);
}
void loop () {}
Compiling for Uno:
Binary sketch size: 2,312 bytes (of a 32,256 byte maximum)
Case 2 uses "and" and "or":
volatile byte bar;
void setup ()
{
Serial.begin (115200);
bar |= 1;
Serial.println (bar & 1);
}
void loop () {}
Compiled for Uno:
Binary sketch size: 2,302 bytes (of a 32,256 byte maximum)
OK, it saved 8 bytes. But now change Case 1 to be:
struct myByte {
byte foo : 1;
};
volatile myByte bar;
void setup ()
{
Serial.begin (115200);
bar.foo = 1;
Serial.println (bar.foo);
}
void loop () {}
(The bit field "foo" changed from int to byte).
Now I get:
Binary sketch size: 2,198 bytes (of a 32,256 byte maximum)
In this particular case, using the bit-field saved 114 bytes of program memory.