1
votes
#include <WProgram.h>
#include <EEPROM.h>

template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
    const byte* p = (const byte*)(const void*)&value;
    int i;
    for (i = 0; i < sizeof(value); i++)
    EEPROM.write(ee++, *p++);
    return i;
}

template <class T> int EEPROM_readAnything(int ee, T& value)
{
    byte* p = (byte*)(void*)&value;
    int i;
    for (i = 0; i < sizeof(value); i++)
        *p++ = EEPROM.read(ee++);
    return i;
}

Hi community, I'm getting the following errors for my code:

EEPROMAnything.h: In function 'int EEPROM_writeAnything(int, const T&)':
EEPROMAnything.h:6: error: expected initializer before '*' token
EEPROMAnything.h:9: error: 'p' was not declared in this scope
EEPROMAnything.h: In function 'int EEPROM_readAnything(int, T&)':
EEPROMAnything.h:15: error: 'byte' was not declared in this scope
EEPROMAnything.h:15: error: 'p' was not declared in this scope
EEPROMAnything.h:15: error: expected primary-expression before ')' token
EEPROMAnything.h:15: error: expected primary-expression before 'void'

Not sure what I'm missing in this set. Would love feedback!
Thanks

1
byte is unknown, and that´s probably the reason for most (or all) of the errors.deviantfan
I´m not sure why, but try to include WConstants.h manuallydeviantfan

1 Answers

0
votes

found out what is not working

 #include <WProgram.h> 

should be instead

 #include <Arduino.h>

thank you for the comments community!