[Top][All Lists]

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

[avr-libc-dev] [bug #25048] eeprom.h will not compile as c++ code.

From: Bob Paddock
Subject: [avr-libc-dev] [bug #25048] eeprom.h will not compile as c++ code.
Date: Tue, 09 Dec 2008 13:45:36 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)


                 Summary: eeprom.h will not compile as c++ code.
                 Project: AVR C Runtime Library
            Submitted by: bpaddock
            Submitted on: Tue 09 Dec 2008 08:45:34 AM EST
                Category: Library
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Header files
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.6.4
           Fixed Release: None



eeprom.h will not compile as C++ code giving this error:

 In function 'uint8_t eeprom_read_byte(const uint8_t*)':

 error: cast from 'const uint8_t*' to 'uint8_t' loses precision

Test case:

-------- begin main.cpp --------
#if defined(__cplusplus) && __cplusplus
 extern "C" {

#include <avr/io.h>
#include <avr/eeprom.h>

#if defined(__cplusplus) && __cplusplus

int main( void ) __attribute__ ((OS_main));
int main( void )
-------- end --------

Suggested solution is to change to:

EEARL = (uint8_t) (uint16_t)__p;


__ATTR_PURE__ static __inline__ uint8_t eeprom_read_byte (const uint8_t

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.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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