The Compiler provides two predefined macros for enabled/disabled type size reduction. With type size reduction 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.
__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 to get optimized bitfields (refer to the following listing):
struct{ long b1:4; long b2:4; } myBitfield; 31 7 3 0 -------------------------------- |########################|b2|b1| -BfaTSRoff -------------------------------- 7 3 0 -------------- | b2 | b1 | -BfaTSRon --------------