Re: Casting function pointers
- From: Habib Bouaziz-Viallet <habib@xxxxxxxxxxxxx>
- Date: 31 Jan 2008 07:18:20 GMT
Le Wed, 30 Jan 2008 10:46:26 -0800, KKL a écrit:
I wonder how casting with function pointers work, how it "should be"(void ()(void)* ) funcPtr does not make any sense.
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);Is your code compiles ? No offense, If so i wish you good luck (and
.........
}
Module: SomeClass.cpp
void someClass::taskLoop( int taskArgument)
{
.......
}
void somClass::initialize( void )
{
taskCreate( "Task1", (void* )&taskLoop, 25,.....);
}
Module: SomeOtherClass.cpp
int myTaskEntryReturnsInt( void )
{
}
SomeOtherClass::initialize( void )
{
taskCreate( "Task2", (void* )&myTaskEntryReturnsInt, 30,.....);
}
Module: AnotherClass.cpp
void myTaskEntryTakesInt( int TaskArg )
{
}
AnotherClass::initialize( void )
{
taskCreate( "Task3", (void* )&myTaskEntryTakesInt, 40,.....);
}
My question is whether these kind of casting for function pointers is
valid. If valid should it work with a predictable behavior or the
behavior is undefined.
therefore to those who work with you)
--
HBV
.
- Follow-Ups:
- Re: Casting function pointers
- From: KKL
- Re: Casting function pointers
- References:
- Casting function pointers
- From: KKL
- Casting function pointers
- Prev by Date: Re: Ubuntu versus Fedora for cross-development host
- Next by Date: Re: searching embedded system
- Previous by thread: Re: Casting function pointers
- Next by thread: Re: Casting function pointers
- Index(es):
Relevant Pages
|