Bitfield Type Reduction

The Compiler provides two predefined macros for enabled/disabled type-size reduction (as shown in the following listing). With type-size red uction enabled, the Compiler is free to reduce the type of a bitfield. For example, if the size of a bitfield is 3, the Compiler uses the char type.

Listing: Bitfield Type-Reduction Macros
__BITFIELD_TYPE_SIZE_REDUCTION__    /* defined if type-size
                                       reduction is enabled  */


__BITFIELD_NO_TYPE_SIZE_REDUCTION__ /* defined if type-size

                                       reduction is disabled */

It is possible to write compatible code over different Compiler vendors and get optimized bitfields (as shown in the following listing).

Listing: Effects of Bitfield Type-Size Reduction
struct{
  long b1:4;

  long b2:4;

} myBitfield;

31                       7  3  0

--------------------------------

|########################|b2|b1| 
-BfaTSRoff

--------------------------------

7   3   0

---------

|b2 |b1 | 
-BfaTSRon

---------