What does this C statement mean?
I came across this line:
void (*(*x)(void (*[10])(int *)))(int *)
Can anybody tell me what it is?
To break this down yourself, start from the inner most parentheses and work your way out.
-
(*[10])
<---- Array of 10 pointers -
(*[10])(int *)
<------ Array of 10 pointers to functions which has a pointer toint
as its argument -
(void (*[10])(int *))
<------ Array of 10 pointers to functions which has a pointer toint
as its argument and returnsvoid
-
(*x)(void (*[10])(int *))
<-------x
is a pointer to a function which has as an argument (an array of 10 pointers to functions which has a pointer to int as its argument and returnsvoid
)
.....
I stopped partway through, but hopefully that helps.
cdecl is very helpful for this kind of thing. It says:
declare x as pointer to function (array 10 of pointer to function (pointer to int) returning void) returning pointer to function (pointer to int) returning void
You can find explanations here:
- How To Read Complicated C Declarations - does not compute
- Reading C type declarations
- C Declarations - Clockwise/Spiral Rule
- C-FAQ Question 1.21 - Complex Declarations
A pointer to a function which has an array of 10 pointers to functions that has int * argument and return type void as argument, and returns a pointer to a function which has int * argument and return type void.
Source