Closed caspehre closed 1 month ago
That's the correct observation, but it's not specific to ESP-IDF.
Ok, then I learned something new, I thought it was reasonable to assume second example should work. I guess this issue is closed then?
Since this seems to be something not specific to xtensa, I close this issue
Yeah, that's just one the many of C language's footguns, unfortunately.
Answers checklist.
General issue report
It seems result of unsigned short arithmetics is treated as signed. Consider following code, the u32 example works, but not the u16 example.
volatile unsigned long u32integer1 = 10; volatile unsigned long u32integer2 = 0xFFFFFFFF;
volatile unsigned short u16integer1 = 10; volatile unsigned short u16integer2 = 0xFFFF;
void AppTask(void){ if ((u32integer1 - u32integer2) > 10){ printf("u32 works\n"); }else{ printf("u32 does not work\n"); } if ((u16integer1 - u16integer2) > 10){ printf("u16 works\n"); }else{ printf("u16 does not work\n"); } }