Solved

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

Posted on 2016-11-05
4
56 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:John Lucas
  • 2
4 Comments
 

Author Comment

by:John Lucas
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:John Lucas
ID: 41877978
Thanks about the library  In my ignorance i did not realise the Arduino was different from standard.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 51
why "." vs "->" 23 119
White board coding practice 3 80
Error C2678: binary '!=': no operator found... 4 42
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now