4.2.6.9
Bit field assignment
CC-RH can switch the order of a bit field.
(1) | Format for specifying bit field assignment |
Specify bit field assignment using the following format.
#pragma bit_order [{left|right}]
|
If left is specified, then members are assigned from the MSB; if right is specified, then they are assigned from the LSB.
Example 1. | The default is right. |
#pragma bit_order right
struct {
unsigned int f1:30;
int f2:14;
unsigned int f3:6;
} flag;
|
The internal representation for the bit field in the above example is as follows.
Figure 4.9 | Internal Representation of Bit Field |
#pragma bit_order left
struct {
unsigned int f1:30;
int f2:14;
unsigned int f3:6;
} flag;
|
The internal representation for the bit field in the above example is as follows.
Figure 4.10 | Internal Representation of Bit Field |
#pragma bit_order right
struct {
int f1:5;
char f2:4;
int f3:6;
} flag;
|
The internal representation for the bit field in the above example is as follows.
Figure 4.11 | Internal Representation of Bit Field |
#pragma bit_order left
struct {
int f1:5;
char f2:4;
int f3:6;
} flag;
|
The internal representation for the bit field in the above example is as follows.
Figure 4.12 | Internal Representation of Bit Field |