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

 
 

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

Submitted by:  Bob Paddock <bpaddock>
Submitted on:  Tue 09 Dec 2008 01:45:34 PM UTC  
 
Category: HeaderSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Header files
Status: FixedPercent Complete: 100%
Assigned to: Dmitry Xmelkov <dmix>Open/Closed: Closed
Release: 1.6.4Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project AdministratorIn charge of this item.
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.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 08 Jan 2009 08:41:43 AM UTCjoerg_wunschOpen/ClosedOpen=>Closed
    Sat 13 Dec 2008 04:41:11 AM UTCdmixCategoryLibrary=>Header
      StatusNone=>Fixed
      Percent Complete0%=>100%
      Assigned toNone=>dmix

    Back to the top


    Powered by Savane 3.1-cleanup1