Re: Casting function pointers
- From: Vladimir Vassilevsky <antispam_bogus@xxxxxxxxxxx>
- Date: Wed, 30 Jan 2008 19:31:32 GMT
KKL wrote:
I wonder how casting with function pointers work, how it "should be"
handled and how it "should not be" handled. Can anyone tell whether
the below code should work or not?
Module: Task Service Abstraction Layer
int taskCreate(char* taskName, void* funcPtr, int
taskPriority,..........)
{
myTaskStructure TaskProperties;
int TaskId, errStatus;
............
//Casting void* funcPtr to function pointer that returns void and
accepts no arguments
TaskProperties.entryPtr = (void ()(void)* ) funcPtr;
errStatus = rtosTaskCreate( taskName, &TaskProperties, &TaskId);
.........
}
Module: SomeClass.cpp
void someClass::taskLoop( int taskArgument)
{
.......
}
void somClass::initialize( void )
{
taskCreate( "Task1", (void* )&taskLoop, 25,.....);
}
Module: SomeOtherClass.cpp
My question is whether these kind of casting for function pointers is
valid.
No it is not. There is plenty of mistakes in your example. The first one: you can't cast a class member function to an ordinary function.
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
.
- References:
- Casting function pointers
- From: KKL
- Casting function pointers
- Prev by Date: RTS CTS Problem
- Next by Date: Re: RTS CTS Problem
- Previous by thread: Re: Casting function pointers
- Next by thread: Re: Casting function pointers
- Index(es):
Relevant Pages
|