[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Warning message
From: |
Gre7g Luterman |
Subject: |
Re: [avr-gcc-list] Warning message |
Date: |
Tue, 2 Oct 2007 23:23:55 -0700 (PDT) |
--- Royce Pereira <address@hidden> wrote:
> What does the following warning mean?
>
> warning: comparison is always true due to limited
> range of data type
It means the if will always happen.
> #define CHK_1307 0x55
> uint8 twi_read(void)
> if(twi_read() != ~CHK_1307) ok= 0;
CHK_1307 = 0x55
so
~CHK_1307 = 0xFFAA
Since twi_read returns a byte, it will never be 0xFFAA
so the if will always happen.
Try casting it back to a byte:
if (twi_read() != ((uint8_t) ~CHK_1307)) ok = 0;
Gre7g
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com