arduino错误:*令牌之前的预期初始化程序

时间:2014-06-02 18:08:44

标签: c++ arduino eeprom

#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:在函数'int EEPROM_writeAnything(int,const T&amp;)'中:   EEPROMAnything.h:6:错误:'*'令牌之前的预期初始化程序   EEPROMAnything.h:9:错误:在此范围内未声明'p'   EEPROMAnything.h:在函数'int EEPROM_readAnything(int,T&amp;)'中:
  EEPROMAnything.h:15:错误:在此范围内未声明'byte'   EEPROMAnything.h:15:错误:在此范围内未声明'p'   EEPROMAnything.h:15:错误:在')'令牌之前预期的primary-expression
  EEPROMAnything.h:15:错误:在'void'之前预期的primary-expression

不确定我在这套中缺少什么。愿意反馈!
感谢

1 个答案:

答案 0 :(得分:0)

发现了什么不起作用

 #include <WProgram.h> 

应该是

 #include <Arduino.h>

感谢您的评论社区!