gpt4 book ai didi

C++ 未解析的重载函数类型

转载 作者:行者123 更新时间:2023-11-28 00:00:01 27 4
gpt4 key购买 nike

<分区>

我遇到了 typedef/回调函数的问题。

typedef void (*timer_cb_fn_t)(void); //defined in timer.h

这里是timer.cpp中定义的timer_start函数的定义

unsigned int TimClass:: timer_start(unsigned int interval, timer_cb_fn_t cb)
{
//do stuff
}

dpl.h包含timer.h

我正在尝试从 dpl.cpp 文件中调用计时器函数其中回调函数定义为

 void Dpl::receive_timeout(void)
{
receive_state = STATE_IDLE;
}

我正在通过以下调用调用函数计时器启动。

unsigned int receive_timer = timer_start(TIMER_FRAME_TIME_MS, receive_timeout);

g++ 编译器抛出以下错误。

./src/dpl/dpl.cc:138:107: error: no matching function for call to ‘TimClass::timer_start(unsigned int, <unresolved overloaded function type>)’
../dpl.cc:138:107: note: candidate is:
../timer.h:256:16: note: unsigned int TimClass::timer_start(unsigned int, timer_cb_fn_t)
../timer.h:256:16: note: no known conversion for argument 2 from ‘<unresolved overloaded function type>’ to ‘timer_cb_fn_t {aka void (*)()}’
make: *** [build/dpl.o] Error 1

您能解释一下如何解决这个问题吗?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com