【发布时间】:2020-05-14 10:47:12
【问题描述】:
当我在 MBED 中使用 InterruptIn 类时,我开始收到此错误。
这是我试图调用的 fall 函数的定义:
这是我的代码:
void Sensor::contador(int cont){
cont++;
}
int Sensor::medidaSensor(){
//Se activa el watchdog:
Timer timer;
timer.start();
int npulsos=0;
while(1){
//Cuenta los pulsos durante 5ms
if (timer.read_ms() < 5)
{
vcomp.fall(&contador(npulsos)); // <= compilation error here
}
else{
//Kick the watchdog to reset its timer
watchdogTimer.kick();
}
}
return npulsos;
}
【问题讨论】:
-
contador()返回void,因此&contador(npulsos)返回一个void类型的右值,您正在尝试获取地址。你想将什么传递给fall函数? -
void表示没有价值,不是object without value。还请将fall的定义发布为文本,而不是图像(阅读idownvotedbecau.se/imageofcode)。
标签: c++ function-pointers rvalue mbed