M
Martin Kojtal
Hello,
the example application is running on 8bit MCU, register is 8 bit wide. There's line where it has to clear the flag with following command:
StructPointer->REGISTER &= ~(FIRST_BIT_MASK);
It issues warning "possible loss of data" which I understand because ~ operator have operands integer type (6.5.4 Expressions). Why the warning disappears when the bit mask is casted to UINT8:
StructPointer->REGISTER &= ~((UINT8)FIRST_BIT_MASK);
I am inclined to cast the result of bitwise complement: (UINT8)(~FIRST_BIT_MASK).
Are both forms correct to suppress the warning?
MartinK
the example application is running on 8bit MCU, register is 8 bit wide. There's line where it has to clear the flag with following command:
StructPointer->REGISTER &= ~(FIRST_BIT_MASK);
It issues warning "possible loss of data" which I understand because ~ operator have operands integer type (6.5.4 Expressions). Why the warning disappears when the bit mask is casted to UINT8:
StructPointer->REGISTER &= ~((UINT8)FIRST_BIT_MASK);
I am inclined to cast the result of bitwise complement: (UINT8)(~FIRST_BIT_MASK).
Are both forms correct to suppress the warning?
MartinK