I have this syntax:
double (*(f(double (*)(int))))(int);
Do I understand correctly syntax above that f is function that gets pointer to function that receive int and return a double?
No; it's actually even more complicated than that.
cdecl.org glosses this type definition as:
declare f as function (pointer to function (int) returning double) returning pointer to function (int) returning double
In other words, the function pointed to by f
takes a function pointer as an argument, and returns a function pointer. Both of those function pointers must be to functions which take an int
as an argument and return a double
.
You could simplify this definition a bit using an intermediate typedef
as follows:
typedef double (*int_to_double_function)(int);
int_to_double_function (*f)(int_to_double_function);