Tue 09 Dec 2008 01:45:34 PM UTC, original submission:
eeprom.h will not compile as C++ code giving this error:
g:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h:
In function 'uint8_t eeprom_read_byte(const uint8_t*)':
g:/winavr-20081205/lib/gcc/../../avr/include/avr/eeprom.h:199:
error: cast from 'const uint8_t*' to 'uint8_t' loses precision
Test case:
-------- begin main.cpp --------
#if defined(__cplusplus) && __cplusplus
extern "C" {
#endif
#include <avr/io.h>
#include <avr/eeprom.h>
#if defined(__cplusplus) && __cplusplus
}
#endif
int main( void ) _attribute_ ((OS_main));
int main( void )
{
for(;;)
;
}
-------- end --------
Suggested solution is to change to:
EEARL = (uint8_t) (uint16_t)__p;
in:
_ATTR_PURE_ static _inline_ uint8_t eeprom_read_byte (const uint8_t *__p)
{
}
It should also be noted that the eeprom_write() functions have simular code, but use less explisit casts of (unsigned). Casts of stdint types would be better to complie with MISRA guidelines.
|