Rae*_*kye 5 c++ string arduino
我正在用C++编写一个用于Arduino 草图的堆栈类.我相信它完全符合AVR(如果这就是它所谓的;我记不清楚)编译器; 我用所有malloc和free替代new和delete等.
所以我的课上有一个.h文件.我已经将它导入到草图中,但是当我尝试编译时,我得到了这些错误:
In file included from sketch_may15a.cpp:1:
/CStack.h:58:18: error: string: No such file or directory
In file included from sketch_may15a.cpp:1:
CStack.h:61: error: variable or field 'Error' declared void
CStack.h:61: error: 'string' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
以下是我班上的前几行:
#include <string>
using namespace std;
void Error(string message) {
Run Code Online (Sandbox Code Playgroud)
所以Arduino编译器找不到<string>,接下来的几个问题似乎与它有关(不确定是什么variable or field Error declared void意思,我的错误函数仅用于调试目的).
我知道Arduino草图支持字符串而不需要导入,但我不确定如何使用C/C++/.h文件.我试过谷歌搜索,但没有太多的文档.
Arduino草图不支持任何C++标准库,因为它们是使用不支持它的avr-libc编译的.但是,Arduino确实提供了String应该做你需要的课程.
如果您正在编写库,则还需要#include <Arduino.h>(或者#include <Wiring.h>如果您使用的是1.1版之前的Arduino IDE).