Arduino错误:* token之前预期的初始化器

arduino error: expected initializer before * token

本文关键字:初始化 错误 token Arduino      更新时间:2023-10-16
#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;
}

嗨社区,我的代码出现了以下错误:

EEPROMAnything.h: In function 'int EEPROM_writeAnything(int, const T&)':
EEPROMAnything.h:6:错误:'*' token之前的期望初始化器
EEPROMAnything.h:9: error: 'p'未在此作用域中声明
EEPROMAnything.h: In function 'int EEPROM_readAnything(int, T&)':
EEPROMAnything.h:15: error: 'byte'未在此作用域中声明
EEPROMAnything.h:15: error: 'p'未在此作用域中声明
EEPROMAnything.h:15:错误:')'标记前的期望主表达式
EEPROMAnything.h:15:错误:'void'之前预期的主表达式

不知道我在这个集合中错过了什么。希望得到反馈!
由于

找出不工作的地方

 #include <WProgram.h> 

应改为

 #include <Arduino.h>

感谢大家的评论!