Compiling this test code with Hi-tech C
issues the following warning
Warning [765] D:\pic experimental\main.c; 7. degenerate unsigned comparison
We well know what the warning means, since x is unsigned, its trivial that x >=0 is always true. But guess what? Its actually error. RC5 isn't set, the statement RC5 = 1; isn't executed at all!
My god, who would have thought like that?
It was part of my bigger program, took my whole day to figure this out.
Code:
#include<htc.h>
void main(){
TRISC5 = 0;
unsigned char x;
x = 5;
if(x >= 0){
RC5 = 1;
}
}
Warning [765] D:\pic experimental\main.c; 7. degenerate unsigned comparison
We well know what the warning means, since x is unsigned, its trivial that x >=0 is always true. But guess what? Its actually error. RC5 isn't set, the statement RC5 = 1; isn't executed at all!
My god, who would have thought like that?
It was part of my bigger program, took my whole day to figure this out.