Tony The Lion
Tony The Lion

Reputation: 63190

What does this C statement mean?

I came across this line:

void (*(*x)(void (*[10])(int *)))(int *)

Can anybody tell me what it is?

Upvotes: 25

Views: 1546

Answers (4)

Jesse Good
Jesse Good

Reputation: 52365

To break this down yourself, start from the inner most parentheses and work your way out.

  1. (*[10]) <---- Array of 10 pointers
  2. (*[10])(int *) <------ Array of 10 pointers to functions which has a pointer to int as its argument
  3. (void (*[10])(int *)) <------ Array of 10 pointers to functions which has a pointer to int as its argument and returns void
  4. (*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 returns void)

.....

I stopped partway through, but hopefully that helps.

Upvotes: 43

Seth Carnegie
Seth Carnegie

Reputation: 75130

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

Upvotes: 10

user142162
user142162

Reputation:

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

Upvotes: 3

Related Questions