S12 bit field define problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12 bit field define problem

541 Views
赵子成
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 Kudos
1 Reply

354 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

Can you please upload your demo project? Thanks

BR

Jennie Zhang

0 Kudos