C programming: void * argument is it really pointer to anything, can I pass function pointer there

Viewed 1712

I consider how should I use void * correctly (I have some break from C language). As I remember void * is used to enable passing any argument to callback function. I know that it is ok to pass something like primitive types int *, const char * or even collection of values as struct attributes *.

I consider whether passing pointer to function as void * will be ok.

ex.

typedef void (*callback_t)(void *);
typedef void (*my_custom_callback_t)( /* list of params */ )

void someAPIFunction( /*... */, callback_t callback, void *callback_param);

void standard_callback(void *param) { 

       ((my_custom_callback_t) param) ( /* my params */ );
}

I consider whether having such types it will be correct to pass my_custom_callback as param to standard_callback?

void my_custom_callback(/* list of params */) { }

someAPIFunction( /*...*/, standard_callback, my_custom_callback); 
3 Answers
Related