本文介绍了Arduino 中“StandardCplusplus"库的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不用 C++ 为 Arduino 编写一些代码.代码运行良好,但不能在 Arduino 中运行,因为我使用了一些库,如向量、ifstream 等.

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.

所以我包含了 StandardCplusplus 库.我下载了 zip 版本的库.

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

我将提取的版本复制到 Arduino 的库文件夹中.现在矢量库可以工作了,即它不会给出任何编译错误.

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.

但是在 #include fstream 上,Arduino 给出以下错误:fatal error: unistd.h: No such file or directory

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

推荐答案

有点晚了,但也许其他人遇到了同样的问题,就像我几分钟前正在寻找答案一样.我通过定义一个符号 ARDUINO(我使用 eclipse,所以我在项目的 Properties --> C/C++ Build 中添加了一个新符号,从而将问题从错误变成了警告> --> Settings --> AVR Compiler/AVR C++ Compiler --> Symbols. 不要知道您在使用什么,但您可以在调用 avr-g++ 时添加 -DARDUINO).问题出在 ios.cpp 文件中,其中包含:#ifdef ARDUINO#include #include #别的#include <fstream>#万一一旦在 ios.cpp 文件中看到 ARDUINO 符号,就会使用两个较早的包含而不是 fstream.

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> #endifAs soon as the ARDUINO symbol is seen in the ios.cpp file, two earlier includes are taken instead of the fstream.

这篇关于Arduino 中“StandardCplusplus"库的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 03:45