Solved

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

Posted on 2016-11-05
4
70 Views
Last Modified: 2016-11-07
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
Comment
Question by:7982681
  • 2
4 Comments
 

Author Comment

by:7982681
ID: 41875737
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
 
LVL 28

Accepted Solution

by:
pepr earned 250 total points
ID: 41875941
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
 
LVL 33

Assisted Solution

by:sarabande
sarabande earned 250 total points
ID: 41876940
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
 

Author Comment

by:7982681
ID: 41877978
Thanks about the library  In my ignorance i did not realise the Arduino was different from standard.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question