First of all: a function pointer refers only to a function. Parameters enter the game when a function is called, either directly or through a function pointer.
So, if you want to achieve what you mean, it is binding (set) of parameters to a specific varaible function, you need to use a wrapper function:
int func1(char * pc) { int i; return i; } int func1_abcd(void) { return func1("abcd") } int func1_xyz(void) { return func1("xyz") } typedef int (*pfunc1_wrapper_t)(void); int func2(pfunc1_wrapper_t pfunc1_wrapper) { return pfunc1_wrapper(); } int main(int argc, char ** argv) { pfunc1_wrapper_t pfunc1_wrapper = NULL; int i = 0; pfunc1_wrapper = func1_abcd; i = func2(pfunc1_wrapper); pfunc1_wrapper = func1_xyz; i = func2(pfunc1_wrapper); ... return 0; }
source share