ISO C++ forbids declaration of 'vector' with no type
arduino, c++
Solution
I just ran into this same issue and was able to resolve it by including StandardCplusplus.h in my main sketch .ino file, rather than in the C++ class header file that I wanted to use the vector in. So, it looks roughly like this:
/*
Main.ino (or whatever your main sketch file is called)
*/
#include <StandardCplusplus.h>
#include "Node.h"
// ...
void setup()
{
}
void loop()
{
}
Then in Node.h:
/*
Node.h
*/
#ifndef Node_h
#define Node_h
#include <vector>
class Node
{
public:
Node();
~Node();
std::vector<int> test;
};
#endif
Problem
I am having an issue with arduino c and the StandardCplusplus package. I am trying to declare a vector but get the following error: Node.h:26: error: ISO C++ forbids declaration of 'vector' with no type Node.h:26: error: invalid use of '::' Node.h:26: error: expected ';'before '<' token Looking at other questions, here or here people forget the include or use std, but I have done both. ``` /* 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 ``` thanks edit: I am using the arduino 1.5.5 ide compiler. edit2: I have removed everything except the vector as per comments yielding: ``` /* Node.h */ #ifndef Node_h #define Node_h #include <vector> class Node { public: Node(); ~Node(); std::vector<int> test; }; #endif ``` which still outputs the error: In file included from Node.cpp:1: Node.h:13: error: ISO C++ forbids declaration of 'vector' with no type Node.h:13: error: invalid use of '::' Node.h:13: error: expected ';' before '<' token