ISO C ++禁止声明无类型的“向量”

Ste*_*gle 5 c++ arduino

我在使用arduino c和StandardCplusplus软件包时遇到问题。我正在尝试声明一个向量,但出现以下错误:

Node.h:26:错误:ISO C ++禁止声明无类型的“向量”

Node.h:26:错误:无效使用'::'

Node.h:26:错误:预期';'在'<'标记之前

在其他问题上,人们在这里这里忘记了include或use 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
Run Code Online (Sandbox Code Playgroud)

谢谢

编辑:我正在使用arduino 1.5.5 ide编译器。

edit2:我删除了除矢量以外的所有内容,按注释产生:

/*
 Node.h
*/
#ifndef Node_h
#define Node_h

#include <vector>
class Node
{
  public:
      Node();
      ~Node();
      std::vector<int> test;
};

#endif
Run Code Online (Sandbox Code Playgroud)

仍然输出错误:

在Node.cpp包含的文件中:1:

Node.h:13:错误:ISO C ++禁止声明无类型的“向量”

Node.h:13:错误:无效使用'::'

Node.h:13:错误:预期为';' 在“ <”令牌之前

小智 3

我刚刚遇到了同样的问题,并且能够通过在我的主 sketch .ino 文件中包含 StandardCplusplus.h 来解决它,而不是在我想要使用向量的 C++ 类头文件中。所以,它看起来大致像这样:

/*
 Main.ino (or whatever your main sketch file is called)
*/

#include <StandardCplusplus.h>
#include "Node.h"

// ...

void setup()
{
}

void loop()
{
}
Run Code Online (Sandbox Code Playgroud)

然后在 Node.h 中:

/*
 Node.h
*/
#ifndef Node_h
#define Node_h

#include <vector>
class Node
{
  public:
      Node();
      ~Node();
      std::vector<int> test;
};

#endif
Run Code Online (Sandbox Code Playgroud)