bugAVR C Runtime Library - Bugs: bug #25048, eeprom.h will not compile as c++...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #25048: eeprom.h will not compile as c++ code.

Submitter:  Bob Paddock <bpaddock>
Submitted:  Tue 09 Dec 2008 01:45:34 PM UTC
   
 
Category:  Header Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Header files
Status:  Fixed Assigned to:  dmix
Percent Complete:  100% Open/Closed:  Closed
Release:  1.6.4 Fixed Release:  None

Sat 13 Dec 2008 04:41:11 AM UTC, comment #1: 

Fixed in both HEAD and 1_6 branches.
Undo the cast operation in the 'eeprom.h' to rev 1.27 (before 2008-08-19).

The item is't closed: it is needed to add the support
C++ files in test suite and it is needed to check other
headers with C++.

Dmitry Xmelkov <dmix>
Group administrator
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.


Bob Paddock <bpaddock>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Updated the item)
  • -email is unavailable- added by dmix (Posted a comment)
  • -email is unavailable- added by bpaddock (Submitted the item)
  •  

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-01-08 joerg_wunsch Open/ClosedOpen Closed
    2008-12-13 dmix CategoryLibrary Header
        StatusNone Fixed
        Percent Complete0% 100%
        Assigned toNone dmix

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code