Type conversion warning after bitwise operations in C

后端 未结 4 1213
傲寒
傲寒 2021-02-20 05:29

How do you explain that line 7 gets a warning, but not line 5 or line 6?

int main()
{
    unsigned char a = 0xFF;
    unsig         


        
4条回答
  •  你的背包
    2021-02-20 06:04

    The return type of bitwise operator & is integer. Whenever you cast an int (4 bytes) into char or unsigned char (1 byte) it gives you warning.

    So this is not related to bitwise operator it is related to typecasting from 4 bytes variable to 1 bytes variable.

提交回复
热议问题