Jos*_*osh 7 c++ typedef arduino
以下草图无法在Arduino环境中编译.
鉴于typedef可以在Arduino软件中使用,自动原型生成是否会导致失败?如果是这样,它是什么,为什么Arduino不提供围绕C++的轻量级包装?
#define PRODUCE_WACKY_COMPILETIME_ERROR
typedef int MyMeaningfulType;
#ifndef PRODUCE_WACKY_COMPILETIME_ERROR
void myFunc(MyMeaningfulType myParam);
#endif
void myFunc(MyMeaningfulType myParam)
{
myFunc(10);
}
void setup() {}
void loop() {}
Run Code Online (Sandbox Code Playgroud)
为了搜索引擎的利益,报告的错误是:
error: variable or field 'myFunc' declared void
error: 'MyMeaningfulType' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
请参阅http://arduino.cc/en/Hacking/BuildProcess具体报价如下:
This means that if you want to use a custom type as a function argument, you should declare it within a separate header file.
Run Code Online (Sandbox Code Playgroud)
这个页面很好地解释了Arduino语言与C/C++的不同之处在于它如何工作/预处理文件.