PC-lint编译问题

2020-02-08 12:22发布

各位,我声明了一个这样的变量:
union
{
    struct
    {
        unsigned cell_cap:3;
        unsigned outpow:1;
        unsigned charging:1;
        unsigned :2;
    }
    unsigned char Byte;
}Power_Info
我做一个判断语句,只能写成这个样子:
if(((Power_Info.Byte & 0x07) == 0x00) && ((Power_Info.Byte & 0x8) == 0x00))
才能用PC-lint编译通过,但这样的话我的变量就直接声明成一个普通的unsigned char就得了,里面的位再细分也白分了。
如果写成这样:
if((Power_Info.cell_cap == 0x00) && (Power_Info.OutPow == 0x00))
就会报错:
Implicit binary conbersion from int to unsigned int
如果写成这样:
if((Power_Info.cell_cap == 0b000) && (Power_Info.OutPow == 0b0))
就会报错:
Assuming a binary constant

高人请指教啊!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。