AnsweredAssumed Answered

S12 bit field define problem

Question asked by 赵子成 on Jun 11, 2018
Latest reply on Jun 14, 2018 by ZhangJennie

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;


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

I don't know why.

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


Thank you.