I am looking at a legacy embedded project with a C30 microchip compiler for a 16-bit MCU. There is an expected case where the index goes around 0xFF, which, as I thought, will be determined by default. However, the following code always resets me to //sad :( when I expect it to end happily.
unsigned char index = 0xFF; unsigned char check = 0x02; if(check == index +3){
Now, if I specifically applied it to an unsigned char :
unsigned char index = 0xFF; unsigned char check = 0x02; if(check == (unsigned char) index +3){
This works, and I end up with //happy! So what did I miss? Is this just compiler dependent behavior?
source share