【问题标题】:Issues with 'StandardCplusplus' Library in ArduinoArduino 中“StandardCplusplus”库的问题
【发布时间】:2015-08-10 13:48:23
【问题描述】:

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

所以我包含了 StandardCplusplus 库。我下载了zip version of the library

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

但在#include fstream,Arduino 给出以下错误:致命错误:unistd.h:没有这样的文件或目录

【问题讨论】:

  • unistd.h 不是 C 或 C++ 标头!这是一个 POSIX 标头。您是如何尝试包含的? #include <sys/unistd.h>您也可以从这里尝试 Arduino Plus https://github.com/smeshlink/Arduino-Plus
  • 抱歉编辑了这个问题。我正在使用 #include 但这是我得到的错误。

标签: c++ arduino


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    相关资源
    最近更新 更多