I'm trying to pass function pointers as arguments in a list of void pointers. However, ISO C forbids storing a function pointer as a void pointer, so I instead use the address of a function pointer variable, as so:
The problem is with the syntax for casting a void pointer back into a pointer to a function pointer. I've tried the following:Code:generic_func( void **args ) { // generic stuff } void callback( void ) { // specific stuff } int main( ) { void (*func)(void) = callback; void *args[] = { &func, ... }; generic_func( args ); }
The first doesn't parse correctly, the second does not dereference into the proper function pointer type. Can anyone suggest the correct syntax for this?Code:void *arg = &func; *(unsigned __stdcall (*)(void *) *)arg... *(unsigned __stdcall (**)(void *))arg...



LinkBack URL
About LinkBacks


