Arduino方法名称与库函数冲突
Arduino method name clashes with library function
我有这个简单的blink示例,修改为声明一个类,其唯一的方法签名与延迟库函数的方法签名匹配。它会使Arduino崩溃,除非我重命名方法。我看到Arduino.h头文件有"extern C"链接说明符,所以不应该有任何名称冲突。你能帮我理解这个错误吗?
致意。
class Wrapper
{
public:
void delay(unsigned long t)
{
delay (t);
}
};
Wrapper wr;
Wrapper* wrp = ≀
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
wrp->delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
wrp->delay(1000); // wait for a second
}
列出的代码有堆栈溢出问题。在Wrapper::delay(unsigned long)
中,delay(t)
再次调用Wrapper::delay
,而不是Arduino delay()
例程。
如果你想在Wrapper::delay
中调用Arduino delay()
例程,你需要像这样限定调用:
class Wrapper
{
public:
void delay(unsigned long t)
{
::delay(t);
}
};
相关文章:
- 库函数需要一个 std::function<void(void)>,如何传入类函数?
- 有没有一个 c++ gmp 库函数与 python gmpy2 库 divm(..) 函数相同?
- 好友库函数可以访问子数据
- 覆盖程序中的标准 C 库函数C++
- 具有同一库的冲突标头版本的依赖项
- VS2017 #error: : snprintf 的宏定义与标准库函数声明冲突
- 在不使用内置库函数的情况下添加字符串,我做错了什么?
- 返回time()库函数的数据类型
- 将C++中的多个参数传递给MatLab共享库函数
- 从另一个动态链接库项目调用静态库函数
- 导入的库函数是否可以在内存中移动
- 带参数的线程调用库函数
- 在 MASM 中调用标准库函数
- 可变参数模板类 - 0 长度包构造函数冲突
- char concat c++ 没有库函数
- 为什么C++ std::min_element 库函数接受采用布尔返回类型的函数对象的函子,而不是像 C 中那样的 in
- 如何在将指针传递给库函数时处理内存管理
- 使库函数模板化以避免编译器指令是否有益?
- 结构被库函数覆盖
- Arduino方法名称与库函数冲突