avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] eeprom.h error: cast from 'const uint8_t*' to 'uint8_


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] eeprom.h error: cast from 'const uint8_t*' to 'uint8_t' loses precision in c++
Date: Mon, 8 Dec 2008 20:30:09 +0100 (MET)

Bob Paddock <address@hidden> wrote:

> g:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h:199:
>  error: cast from 'const uint8_t*' to 'uint8_t' loses precision

Hmm, I wonder how we (as the authors of the library) could convince
GCC that this is OK in this case.  The respective code is:

__ATTR_PURE__ static __inline__ uint8_t eeprom_read_byte (const uint8_t *__p)
{
    do {} while (!eeprom_is_ready ());
#if E2END <= 0xFF
    EEARL = (uint8_t)__p;
#else
    EEAR = (uint16_t)__p;
#endif

....so the cast from pointer to uint8_t is only applied in situations
where we *know* the target AVR does not have more than 256 EEPROM
addresses, so losing precision is OK here.

Curious, if you replace that by a cast to uint16_t (which then gets
assigned to a uint8_t register), will it still complain?

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]