S12 bit field define problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S12 bit field define problem

886件の閲覧回数
赵子成
Contributor IV

Hi everyone,

I defined a variable via bit field way as follow:

typedef struct stAbbrTime_t

{

UINT32 Sec : 6;
UINT32 Min : 6;
UINT32 Hour : 5;
UINT32 Day : 5;
UINT32 Month : 4;
UINT32 Year : 6;

}ST_ABBR_TIME;

I think this variable must be 4 bytes length, but in fact it occupy 5 bytes as follow:

pastedImage_2.png

I don't know why.

The bit field settings in CW5.1 is as follow(I use the default setting)

pastedImage_3.png

Thank you.

0 件の賞賛
返信
1 返信

699件の閲覧回数
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

Can you please upload your demo project? Thanks

BR

Jennie Zhang

0 件の賞賛
返信