[英]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.