Node.h:26: 错误: ISO C++禁止在没有类型的情况下声明“vector” Node.h:26: 错误: 无效的使用'::' Node.h:26: 错误: 在“<”标记之前预期';'
查看其他类似问题的解决方案,如这里或这里,人们会忘记包含头文件或使用std,但我已经做了这两个步骤。
/*
Node.h
*/
#ifndef Node_h
#define Node_h
#include "Arduino.h"
#include <StandardCplusplus.h>
#include <vector>
#include <string>
#include <iterator>
class Node
{
public:
Node(int size);
~Node();
float bias();
void set_bias(float);
void print();
void fprint(FILE *);
float compute(std::vector<float> inputs);
void setWeights(std::vector<float> inws);
void set_weight(int,float);
float dutyCycle();
protected:
std::vector<float> _weights; //input weights:30
float level;
void init(int size);
std::vector<int> firelog;
};
#endif
谢谢。
编辑:我正在使用arduino 1.5.5 ide编译器。
编辑2:根据评论,我已经删除了除向量以外的所有内容,即:
/*
Node.h
*/
#ifndef Node_h
#define Node_h
#include <vector>
class Node
{
public:
Node();
~Node();
std::vector<int> test;
};
#endif
仍然输出错误:
从Node.cpp中包含的文件:
Node.h:13:错误:ISO C++禁止未定义类型的“vector”声明
Node.h:13:错误:无效使用“::”
Node.h:13:错误:在“<”符号之前应有“;”
"Arduino.h"
或<StandardCplusplus.h>
搞出了什么奇怪的事情,否则看起来应该可以编译。我建议使用普遍存在的-E
选项对文件进行预处理,然后查看有问题的行变成了什么。 - Dietmar Kühl