Issues with 'StandardCplusplus' Library in

2019-08-14 03:43发布

问题:

I had to write some code for Arduino in C++. The code works perfectly, but wouldn't work in Arduino as I had used some libraries like vectors, ifstream, etc.

So I included the StandardCplusplus library. I downloaded the zip version of the library.

I copied the extracted version into the library folder of Arduino. Now the vector library works, i.e. it doesn't give any compile error.

But on #include fstream, Arduino gives the following error: fatal error: unistd.h: No such file or directory

回答1:

A bit late, but maybe someone else encounters the same problem, just like me looking for an answer couple of minutes ago. I turned the problem from an error to a warning by defining a symbol ARDUINO (I use eclipse, so I added a new symbol in the project's Properties --> C/C++ Build --> Settings --> AVR Compiler / AVR C++ Compiler --> Symbols. Don't know what you're using, but you could add -DARDUINO when calling avr-g++). The problem is in ios.cpp file, where you have: #ifdef ARDUINO #include <HardwareSerial.h> #include <serstream> #else #include <fstream> #endif As soon as the ARDUINO symbol is seen in the ios.cpp file, two earlier includes are taken instead of the fstream.



标签: c++ arduino