C++ – arduino error: expected initializer before * token

arduinoceeprom

#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

Best Answer

found out what is not working

 #include <WProgram.h> 

should be instead

 #include <Arduino.h>

thank you for the comments community!

Related Topic