CODE GENERATION
Function
-BfaB(MS|LS)
MS: Most significant bit in byte first (left to right)
LS: Least significant bit in byte first (right to left)
-BfaBLS
__BITFIELD_MSWORD_FIRST__
__BITFIELD_LSWORD_FIRST__
__BITFIELD_MSBYTE_FIRST__
__BITFIELD_LSBYTE_FIRST__
__BITFIELD_MSBIT_FIRST__
__BITFIELD_LSBIT_FIRST__
None
Normally, bits in byte bitfields are allocated from the least significant bit to the most significant bit. This produces less code overhead if a byte bitfield is allocated only partially.
The following listing uses the default condition and uses the three least significant bits.
struct {unsigned char b: 3; } B; // the default is using the 3 least significant bits
This allows just a mask operation without any shift to access the bitfield.
To change this allocation order, you can use the -BfaBMS or -BfaBLS options, shown in the the following listing.
struct { char b1:1; char b2:1; char b3:1; char b4:1; char b5:1; } myBitfield; 7 0 -------------------- |b1|b2|b3|b4|b5|####| (-BfaBMS) -------------------- 7 0 -------------------- |####|b5|b4|b3|b2|b1| (-BfaBLS) --------------------