[英]Arduino method name clashes with library function
我有一个简单的眨眼示例,将其修改为声明一个类,其唯一的方法签名与延迟库函数的签名匹配。 除非我重命名该方法,否则它会使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);
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.