Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91776

Forum Post: RE: the bitfield of struct in big-endian device

$
0
0

third,in my test I defined a struct,

typedef union
{
struct
{
uint16 SelfCheckG : 1; 
uint16 Charge : 1; 
uint16 Modulate : 1; 
uint16 DischargeRotor : 1; 
uint16 Bit4 : 1; 
uint16 Bit5 : 1; 
uint16 Bit6 : 1; 
uint16 Bit7 : 1;
uint16 SelfCheckR : 1;
uint16 Synchronize : 1;
uint16 Connect : 1; 
uint16 FaultReset : 1; 
uint16 Bit12 : 1; 
uint16 Bit13 : 1; 
uint16 Bit14 : 1; 
uint16 Bit15 : 1;
} B;
uint16 all;
} unAppMainCtrlWordMode4;

And in the view of memory,it  shows:

It shows the first member SelfCheckG as the bit0.And you said that the first member will be the MSB,the same as  C compiler user guide indicate that Bit fields are packed in memory from most significant byte to least  significant byte .It's incompatible that SelfCheckG is bit0 and at the same time MSB.


Viewing all articles
Browse latest Browse all 91776

Trending Articles