Solved

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

Posted on 2016-11-05
4
81 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 29

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

829 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