• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

fatal error: vector: No such file or directory Visual Studio 2015 for Arduino

Visual Studio 2015 for Arduino C++.  

My first program gives "fatal error: vector: No such file or directory".  Tried various option from web such as vector.h etc.

#include <vector>
using std::vector;

void setup() {
      Serial.begin(9600);
}

void loop() {
      std::vector<int> newvector;
      Serial.println("Hi");
      delay(100);
}
0
7982681
Asked:
7982681
  • 2
2 Solutions
 
7982681Author Commented:
Or, to put it another way that I think is related, I can put:

String xx = "";

in the .ino file but not in a .cpp file!

I'm assuming some library or reference is needed.

I get these same problems with Eclipse (Arduino version) and Visual Studio for Arduino!!!
0
 
peprCommented:
I do not actively use Arduino. However, it seems that its language is not the C++ language. It is only a subset that uses the same syntax. (Correct me if I am wrong.) And the subset does not have the Standard C++ Library. And there may be good reasons for that.

The implementation of the C++ Standard Library is always directly bound to the compiler and possibly to the hardware target. The reasons are that the implementation should be as efficient as possible for the hardware

It is clear that there are more people like you who are used to C++ and would like to have the std:: functionality. Therefore, you should search for a third party implementation -- like here:

https://github.com/maniacbug/StandardCplusplus

This is just the first thing that I have found. You may want to search further.
0
 
sarabandeCommented:
to add to above: there are a few ports of STL that could be used. for example check

http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/

Sara
0
 
7982681Author Commented:
Thanks about the library  In my ignorance i did not realise the Arduino was different from standard.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now