[英]arduino error: expected initializer before * token
#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:在函数“int EEPROM_writeAnything(int, const T&)”中:
EEPROMAnything.h:6: error: expected initializer before '*' token EEPROMAnything.h:6:错误:“*”令牌之前的预期初始化程序
EEPROMAnything.h:9: error: 'p' was not declared in this scope EEPROMAnything.h:9:错误:“p”未在此范围内声明
EEPROMAnything.h: In function 'int EEPROM_readAnything(int, T&)': EEPROMAnything.h:在函数“int EEPROM_readAnything(int, T&)”中:
EEPROMAnything.h:15: error: 'byte' was not declared in this scope EEPROMAnything.h:15:错误:未在此范围内声明“字节”
EEPROMAnything.h:15: error: 'p' was not declared in this scope EEPROMAnything.h:15: 错误: 'p' 未在此范围内声明
EEPROMAnything.h:15: error: expected primary-expression before ')' token EEPROMAnything.h:15: 错误: ')' 标记之前的预期主表达式
EEPROMAnything.h:15: error: expected primary-expression before 'void' EEPROMAnything.h:15:错误:“void”之前的预期主表达式
Not sure what I'm missing in this set.不确定我在这组中缺少什么。 Would love feedback!希望得到反馈!
Thanks谢谢
found out what is not working发现什么不起作用
#include <WProgram.h>
should be instead应该改为
#include <Arduino.h>
thank you for the comments community!感谢社区的评论!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.