1
#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

4

1 回答 1

0

发现什么不起作用

 #include <WProgram.h> 

应该改为

 #include <Arduino.h>

感谢社区的评论!

于 2014-06-04T03:58:05.647 回答