I just wrote a class for a project that I'm currently working on, but unfortunately I wrote the class before I realized that arduino doesn't have vector support out-of-the-box. Is there a way to add vector support or do I have to re-write my class to use arrays instead?
You can install the STL:
Thanks a lot for the advice. Maybe you could help me with the installation? I downloaded the STL zip file and extracted all of the contents to my /usr/lib/avr/include/avr/ directory (which I believe is the correct directory for linux). I then tried to recompile my program, but got the same error saying that with my included class, "fatal error: vector: No such file or directory". I then tried to include <pnew.cpp> which Andy's website mentioned, but that didn't seem to help either. Thanks.
While I'm at it, maybe I can ask, Why doesn't arduino support things like vector or fstream by default anyway?
extracted all of the contents to my /usr/lib/avr/include/avr/ directory (which I believe is the correct directory for linux).
He didn't say to put it there. You need to put it (the contents of avr-stl/include from the download) into:
That is:
<wherever>/arduino-1.0.1/hardware/tools/avr/lib/avr/include
Then, for me, this test compiled:
#include <iterator>
#include <vector>
#include <pnew.cpp>
void setup ()
{
Serial.begin (115200);
std::vector<int> vec;
std::vector<int>::const_iterator it;
int i;
vec.reserve(50);
for(i=0;i<50;i++)
vec.push_back(i);
for(it=vec.begin();it!=vec.end();it++)
Serial.println (*it);
}
void loop () {}
joethesupercow:
While I'm at it, maybe I can ask, Why doesn't arduino support things like vector or fstream by default anyway?
Don't know.