【问题标题】:arduino error: expected initializer before * tokenarduino 错误:*令牌之前的预期初始化程序
【发布时间】:2014-07-22 22:25:57
【问题描述】:
#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&)”中:
EEPROMAnything.h:6:错误:“*”令牌之前的预期初始化程序
EEPROMAnything.h:9:错误:“p”未在此范围内声明
EEPROMAnything.h:在函数“int EEPROM_readAnything(int, T&)”中:
EEPROMAnything.h:15:错误:未在此范围内声明“字节”
EEPROMAnything.h:15:错误:“p”未在此范围内声明
EEPROMAnything.h:15: 错误: ')' 令牌之前的预期主表达式
EEPROMAnything.h:15: 错误: 'void' 之前的预期主表达式

不确定我在这组中缺少什么。希望得到反馈!
谢谢

【问题讨论】:

  • 字节未知,这可能是大多数(或全部)错误的原因。
  • 我不知道为什么,但尝试手动包含 WConstants.h

标签: c++ arduino eeprom


【解决方案1】:

发现什么不工作

 #include <WProgram.h> 

应该改为

 #include <Arduino.h>

感谢 cmets 社区!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多