M
Mike
I want to pass the address of a function to a timeout type class so that
it can be used as a callback function.
The function I want to use as a callback is defined like...
void rf04::rc_proc(void)
{
}
The call to the the function that uses this functions' address is like...
rctimer=new Timeout(rf04::rc_proc);
But the compiler complains with ...
h:\work\telemetry\rf04.cpp(81) : error C2664: 'Timeout::Timeout' :
cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)'
I tried defining my callback function as
_CRTIMP void __cdecl rf04::rc_proc(void)
but then the compiler complained that I was not allowed to use dllimport
functions in this way.
Linux and g++ complains in a different way...
g++ -Wall -g -O -c rf04.cpp
rf04.cpp: In method `rf04::rf04 (char *)':
rf04.cpp:82: assuming & on `rf04::rc_proc'
rf04.cpp:82: no matching function for call to `Timeout::Timeout (void
(rf04::*) ())'
timeout.h:19: candidates are: Timeout::Timeout (void (*) (), unsigned
int = 1000)
timeout.h:29: Timeout::Timeout (const Timeout &)
make: *** [rf04.o] Error 1
I'm at bit of a loss to understand what is going on. I never really
understood #pragma and stuff like that, but I suspect it's siomething to
do with that.
If my call back function was a global function and not part of a class
then the code compiles and runs OK.
Can anyone give me some clues on this.
Thanks.
it can be used as a callback function.
The function I want to use as a callback is defined like...
void rf04::rc_proc(void)
{
}
The call to the the function that uses this functions' address is like...
rctimer=new Timeout(rf04::rc_proc);
But the compiler complains with ...
h:\work\telemetry\rf04.cpp(81) : error C2664: 'Timeout::Timeout' :
cannot convert parameter 1 from 'void (void)' to 'void (__cdecl *)(void)'
I tried defining my callback function as
_CRTIMP void __cdecl rf04::rc_proc(void)
but then the compiler complained that I was not allowed to use dllimport
functions in this way.
Linux and g++ complains in a different way...
g++ -Wall -g -O -c rf04.cpp
rf04.cpp: In method `rf04::rf04 (char *)':
rf04.cpp:82: assuming & on `rf04::rc_proc'
rf04.cpp:82: no matching function for call to `Timeout::Timeout (void
(rf04::*) ())'
timeout.h:19: candidates are: Timeout::Timeout (void (*) (), unsigned
int = 1000)
timeout.h:29: Timeout::Timeout (const Timeout &)
make: *** [rf04.o] Error 1
I'm at bit of a loss to understand what is going on. I never really
understood #pragma and stuff like that, but I suspect it's siomething to
do with that.
If my call back function was a global function and not part of a class
then the code compiles and runs OK.
Can anyone give me some clues on this.
Thanks.