http://www.opcube.com/home.html#MIDE51
here's my code:
1 | #include <AT89X52.h>
2 |
3 | char BUF = 0b11111111;
4 |
5 | main()
6 | { while(1)
7 | { if (BUF % 2 == 0)
8 | { switch (BUF)
9 | { case 0b11111111 : P0_0 = 0; break;
10| } } } }
here's the error:
C:\DOCUME~1\Arvie\Desktop\NEWFOL~1\ask.c(8) : warning 94: comparison is always true resp. false due to limited range of data type
C:\DOCUME~1\Arvie\Desktop\NEWFOL~1\ask.c(8) : warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
C:\DOCUME~1\Arvie\Desktop\NEWFOL~1\ask.c(9) : warning 126: unreachable code
C:\DOCUME~1\Arvie\Desktop\NEWFOL~1\ask.c(7) : warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG
I dont know why there's an error.
It says that "false due to limited range of data type".
the error only occurs when the 0bxxxxxxxx
in the line case 0b11111111 : P0_0 = 0; break; above
is equal to 0b10000000 to 0b11111111.
when it is 0b00000000 to 0b01111111, there's no error.
I fixed the problem by replacing
char BUF = 0b11111111; to int BUF = 0b11111111;
char 8bit 1byte 0 to 255
int 16bit 2bytes 0 to 65535
but I still want to know why the error occurs.
