TeensyDuino 1.29 gives EEPROM warning. I suggest the fix...

Status
Not open for further replies.

RichardFerraro

Well-known member
When compiling the example program eeprom_put I get:

C:\Arduino\hardware\teensy\avr\libraries\EEPROM/EEPROM.h:144:15: warning: variable 'e' set but not used [-Wunused-but-set-variable]

EEPtr e = idx;

^

C:\Arduino\hardware\teensy\avr\libraries\EEPROM/EEPROM.h: In instantiation of 'const T& EEPROMClass::put(int, const T&) [with T = MyObject]':

C:\Arduino\hardware\teensy\avr\libraries\EEPROM\examples\eeprom_put\eeprom_put.ino:52:36: required from here

C:\Arduino\hardware\teensy\avr\libraries\EEPROM/EEPROM.h:144:15: warning: variable 'e' set but not used [-Wunused-but-set-variable]


I suggest this:
template< typename T > const T &put( int idx, const T &t ){
// EEPtr e = idx; // FERRARO removed declaration from here
const uint8_t *ptr = (const uint8_t*) &t;
#ifdef __arm__
eeprom_write_block(ptr, (void *)idx, sizeof(T));
#else
EEPtr e = idx; // FERRARO Moved declaration here
for( int count = sizeof(T) ; count ; --count, ++e ) (*e).update( *ptr++ );
#endif
return t;
}
 
Status
Not open for further replies.
Back
Top