This is similar to the question in Function pointer with undetermined paramater but when I tried it ,I get a compile errors:
error: too many arguments to function 'accessVariant'
error: void value not ignored as it ought to be
I define this at the top of my C file:
typedef void (*callBackHandler)(void*);
callBackHandler accessVariant= NULL;
I have a call back registration function:
void registerCallbackHandler(callBackHandler ptr_reg_callback)
{
if (ptr_reg_callback == NULL)
{
return;
}
else
{
accessVariant = ptr_reg_callback;
}
}
Inside the code I check for some boolean ,and then I register a specific type of access function:
if (bool)
{
registerCallbackHandler((callBackHandler)aRead16);
}
else
{
registerCallbackHandler((callBackHandler)aRead32);
}
Each of aRead16 and aRead32 takes different kinds of arguments.
Then I make the call:
(*accessVariant)( (void*)arg1,(void*) arg2, (void*)&value )