Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this C statement mean?

Tags:

I came across this line:

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

Can anybody tell me what it is?

like image 431
Tony The Lion Avatar asked Nov 23 '11 21:11

Tony The Lion


People also ask

What is meant by C statement?

C statements consist of tokens, expressions, and other statements. A statement that forms a component of another statement is called the "body" of the enclosing statement. Each statement type given by the following syntax is discussed in this section.

What does $$ mean in C?

It's an identifier character, just like alphanumeric characters and underscores. Allowing $ in identifiers is a GNU extension to C and C++. You can enable it explicitly with the -fdollars-in-identifiers flag. Here it seems to be used in a naming convention where $$ separates namespace components.

Does C have reference?

No, it doesn't. It has pointers, but they're not quite the same thing. For more details about the differences between pointers and references, see this SO question.


1 Answers

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.

like image 175
Jesse Good Avatar answered Oct 25 '22 18:10

Jesse Good