I came across a strange function pointer,
void * (*f1(void(*f2)(void)))(int ) ;
What does the f1
represent here ?
I came across a strange function pointer,
void * (*f1(void(*f2)(void)))(int ) ;
What does the f1
represent here ?
T (*f(U))(V)
declares f
as a function which takes a U
and returns a pointer to a function from V
to T
(i.e. a T (*)(V)
).
So f1
is a function that takes a void (*)(void)
and returns a void* (*)(int)
.
Naming the types makes it more readable:
typedef void (*parameter)();
typedef void* (*result)(int);
result f1(parameter f2);
(The name "f2" serves no purpose except for helping the human reading the code interpret it.)