C 抽象声明符C Abstract Declarators

抽象声明符是没有标识符的声明符,由一个或多个指针、数组或函数修饰符组成。An abstract declarator is a declarator without an identifier, consisting of one or more pointer, array, or function modifiers. 指针修饰符 (*) 始终在声明符中的标识符前面;数组 ([ ]) 和函数 ( ( ) ) 修饰符紧跟在标识符后面。The pointer modifier (\) always precedes the identifier in a declarator; array ([ ]) and function ( **( )* ) modifiers follow the identifier. 了解这种情况后,您可以确定标识符将在抽象声明符中显示的位置并相应地解释声明符。Knowing this, you can determine where the identifier would appear in an abstract declarator and interpret the declarator accordingly. 有关复杂声明符的其他信息和示例,请参阅解释更复杂的声明符See Interpreting More Complex Declarators for additional information and examples of complex declarators. 通常 typedef 可用于简化声明符。Generally typedef can be used to simplify declarators. 请参阅 Typedef 声明See Typedef Declarations.

抽象声明符可能很复杂。Abstract declarators can be complex. 复杂的抽象声明符中的括号指定一个特定的解释,正如它们为声明中的复杂声明符所做的一样。Parentheses in a complex abstract declarator specify a particular interpretation, just as they do for the complex declarators in declarations.

以下示例阐释了抽象声明符:These examples illustrate abstract declarators:

int *         // The type name for a pointer to type int:  

int *[3]      // An array of three pointers to int  

int (*) [5]   // A pointer to an array of five int  

int *()       // A function with no parameter specification  
              // returning a pointer to int  

// A pointer to a function taking no arguments and   
// returning an int  

int (*) ( void )    

// An array of an unspecified number of constant pointers to   
// functions each with one parameter that has type unsigned int   
// and an unspecified number of other parameters returning an int   

int (*const []) ( unsigned int, ... )  


不允许使用由一组空括号 ( ) 组成的抽象声明符,因为它的意义不明确。The abstract declarator consisting of a set of empty parentheses, ( ), is not allowed because it is ambiguous. 无法确定隐含标识符是位于括号内(此时它是未修改类型)还是括号前(此时它是函数类型)。It is impossible to determine whether the implied identifier belongs inside the parentheses (in which case it is an unmodified type) or before the parentheses (in which case it is a function type).

请参阅See Also

声明符和变量声明Declarators and Variable Declarations