以“StandardCplusplus”中的Arduino库问题 [英] Issues with 'StandardCplusplus' Library in Arduino

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

问题描述

我不得不写一些code为Arduino的在C ++中。在code完美的作品,但我用了像载体,ifstream的,等一些库中的Arduino是行不通的。

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库。我下载了库的压缩版本。

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的提供了以下错误:致命错误:unistd.h中:没有这样的文件或目录

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

推荐答案

一个有点晚,但也许别人遇到了同样的问题,就像我在寻找一个答案几分钟前。我通过定义符号ARDUINO(我用eclipse变成了问题,从一个错误的警告,所以我增加了项目的属性一个新的符号 - > C / C ++编译 - > 设置 - > AVR编译器 / AVR C ++编译器 - > 符号不知道你使用的是什么,但你可以添加<$ C调用AVR-G当$ C> -DARDUINO ++)。问题出在ios.cpp文件,其中有:

    #IFDEF ARDUINO
    #包括LT&;&HardwareSerial.h GT;
    #包括LT&;&sers​​tream GT;
    #其他
    #包括LT&;&的fstream GT;
    #万一

只要Arduino的符号在ios.cpp文件中看到,前两次包括采取的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> #endif As soon as the ARDUINO symbol is seen in the ios.cpp file, two earlier includes are taken instead of the fstream.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆