This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
typedef struct
{
Uint16 bSW1:1; //对应拨码开关SW1
Uint16 bSW2:1; //对应拨码开关SW2
Uint16 bSW3:1; //对应拨码开关SW3
Uint16 bSW4:1; //对应拨码开关SW4
Uint16 bvsd:12;
}HardwardInputs;
//输入信号应用层
typedef struct
{
Uint16 bDir:1; //方向选择位,对应拨码开关SW1
Uint16 bCurrent:3; //电流档选择位,对应拨码开关SW2、sw3,sw4
Uint16 bvsd:12;
}AppInputs;
union UNINPUTS
{
HardwardInputs bit1;
AppInputs bit2;
Uint16 all;
};
UNINPUTS MyInputs;
请问是否有办法找出结构体AppInputs类型定义的每个bit位的大小和偏移?比如bCurrent这一位的bit数为(3个)、偏移值为(1)?
其实就是相当于sizeof函数和取地址操作,请问有对应的办法吗?