ISO/IEC 9899:2011 条款6.7.7——类型名

6.7.7 类型名


语法

1、type-name:

        specifier-qualifier-list    abstract-declaratoropt

        abstract-declarator:

            pointer

            pointeropt    direct-abstract-declarator

    direct-abstract-declarator:

        (    abstract-declarator    )

        direct-abstract-declaratoropt    [    type-qualifier-listopt    assignment-expressionopt   ]

        direct-abstract-declaratoropt    [    static    type-qualifier-listopt    assignment-expression    ]

        direct-abstract-declaratoropt    [    type-qualifier-list    static    assignment-expression    ]

        direct-abstract-declaratoropt    [    *    ]

        direct-abstract-declaratoropt    (   parameter-type-listopt    )

 

语义

2、在若干个上下文中,有必要指定一个类型。这通过使用一个类型名来实现,这在语法上是对该类型的一个函数或一个对象的声明,此对象或函数省略了标识符。[注:正如语法所指定的那样,一个类型名中的空的圆括号被解释为“不带形参说明的函数”,而不是围在省略的标识符周围的冗余的圆括号。]

3、例 以下构造:

(a)    int

(b)    int *

(c)    int * [3]

(d)    int (*) [3]

(e)    int (*) [*]

(f)    int * ()

(g)    int (*) (void)

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

分别命名了:(a)int,(b)指向int的指针,(c)带有三个指向int指针的数组,(d)指向一个带有三个int的数组的指针,(d)指向一个未指定int个数的可变长数组的指针,(f)不带有指定形参的,返回指向int的指针的函数,(g)指向不带有任何形参,返回一个int的函数的指针,(h)一个带有未知个数的,指向函数的常量指针的数组,函数的第一个参数类型是unsigned int,紧接着是未指定参数个数的形参,返回为一个int

posted @ 2015-12-02 14:03  zenny_chen  Views(347)  Comments(0Edit  收藏  举报