avr-libc-dev
[Top][All Lists]
Advanced

[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)

URL:
  <http://savannah.nongnu.org/bugs/?25048>

                 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

    _______________________________________________________

Details:


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.






    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?25048>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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