1

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

2
  • unistd.h is not a C or a C++ header! It is a POSIX header.How did you try to include ? #include <sys/unistd.h> You can also try Arduino Plus from here https://github.com/smeshlink/Arduino-Plus Commented Aug 10, 2015 at 14:01
  • Sorry edited the question. I was using #include<fstream> but that is the error I got. Commented Aug 10, 2015 at 14:07

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.