typedef/콜백 함수에 문제가 있습니다. 여기 C++ 해결되지 않은 오버로드 된 함수 유형
typedef void (*timer_cb_fn_t)(void); //defined in timer.h
이 timer_start 함수의 정의는 timer.cpp에 정의되어
unsigned int TimClass:: timer_start(unsigned int interval, timer_cb_fn_t cb)
{
//do stuff
}
dpl.h는 timer.h
내가 dpl.cpp 파일에서 타이머 함수를 호출하려고 포함 내가 invo입니다
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
이 문제를 해결하는 방법을 알려주십시오.
항상 내가 주석으로 게시하도록하겠습니다, A [mcve] –
하지 답변을 게시하시기 바랍니다 : 당신이 C에서 함수 포인터를 사용할 수 없습니다 ++. 여전히 특정 상황에서 유용하지만, 템플릿/펑터와 그 사이의'std :: function'은 대부분의 유스 케이스를 더 잘 처리한다고 생각합니다. –
C++의 차세대 언어 인 C++ + (제목에 지정된대로)를 모르십니까? :) – nosbor