解释复杂声明符Interpreting More Complex Declarators

1. 从标识符开始并直接查找方括号或圆括号（如果有）的右侧。Start with the identifier and look directly to the right for brackets or parentheses (if any).

2. 解释这些方括号或圆括号，然后查找星号的左侧。Interpret these brackets or parentheses, then look to the left for asterisks.

3. 如果在任何阶段遇到一个右圆括号，请返回并将规则 1 和 2 应用于圆括号内的所有内容。If you encounter a right parenthesis at any stage, go back and apply rules 1 and 2 to everything within the parentheses.

4. 应用类型说明符。Apply the type specifier.

``````char *( *(*var)() )[10];
^   ^  ^ ^ ^   ^    ^
7   6  4 2 1   3    5
``````

1. 标识符 `var` 声明为The identifier `var` is declared as

2. 指向以下内容的指针a pointer to

3. 返回以下内容的函数a function returning

4. 指向以下内容的指针a pointer to

5. 包含 10 个元素的数组，这些元素分别为an array of 10 elements, which are

6. 指向以下内容的指针pointers to

7. `char` 值。`char` values.

示例Examples

``````int *var[5]; /* Array of pointers to int values */
``````

``````int (*var)[5]; /* Pointer to array of int values */
``````

``````long *var( long, long ); /* Function returning pointer to long */
``````

``````long (*var)( long, long ); /* Pointer to function returning long */
``````

``````struct both       /* Array of pointers to functions */
{                 /*   returning structures         */
int a;
char b;
} ( *var[5] )( struct both, struct both );
``````

``````/* ILLEGAL */
struct both *var[5](struct both, struct both);
``````

``````unsigned int *(* const *name[5][10] ) ( void );
``````

`name` 数组具有组织在一个多维数组中的 50 个元素。The `name` array has 50 elements organized in a multidimensional array. 这些元素是指向常量指针的指针。The elements are pointers to a pointer that is a constant. 此常量指针指向没有参数并返回指向无符号类型的指针的函数。This constant pointer points to a function that has no parameters and returns a pointer to an unsigned type.

``````double ( *var( double (*)[3] ) )[3];
``````

``````union sign         /* Array of arrays of pointers */
{                  /* to pointers to unions       */
int x;
unsigned y;
} **var[5][5];
``````

``````union sign *(*var[5])[5]; /* Array of pointers to arrays
of pointers to unions        */
``````