typedef struct
{
unsigned char unused_bits:4;
unsigned char wchair_state:2;
} xyz;
typedef struct
{
unsigned char unused_bits;
unsigned char wchair_state;
} abc;
上面的xyz和abc有什么区别?
Xyz占了1 Byte,abc占了2 byte。冒号后表示位域,即该变量存储时占用的位数。
typedef struct
{
unsigned char unused_bits:4;
unsigned char wchair_state:2;
} xyz;
typedef struct
{
unsigned char unused_bits;
unsigned char wchair_state;
} abc;
上面的xyz和abc有什么区别?
Xyz占了1 Byte,abc占了2 byte。冒号后表示位域,即该变量存储时占用的位数。