[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Warning message
From: |
Royce Pereira |
Subject: |
Re: [avr-gcc-list] Warning message |
Date: |
Thu, 04 Oct 2007 10:52:07 +0530 |
User-agent: |
Opera Mail/9.22 (Win32) |
Hi,
On Wed, 03 Oct 2007 20:58:55 +0530, David Kelly <address@hidden> wrote:
> On Wed, Oct 03, 2007 at 08:49:31PM +0530, Royce Pereira wrote:
>> >
>> > #define CHK_1307 ((uint8_t) 0x55)
>> >
>> Actually this worked:
>>
>> Changing the offending line to:
>>
>> if(twi_read() != (uint8_t)~CHK_1307) ok= 0;
>
> While the result is the same, notice the difference between:
>
> (uint8_t)(~(0x55)) and ~((uint8_t)(0x55))
>
> When 0x55 is sitting around bare its an int. The 2nd example puts it
> into uint8_t first, then complements and remains uint8_t.
No, try it.
Even if 0x55 is declared uint8_t, it is still promoted to int before
complementing.
We have to declare it uint8_t *after* complementing (1st example), else the
warning still appears.
> The first
> complements the int then chops it down to fit in a uint8_t.
>
--Royce
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/