6.7.6 Type names

Previous Table of Contents "New C Standard" commentary

1624

type-name:
                specifier-qualifier-list abstract-declaratoropt

abstract-declarator: pointer pointeropt direct-abstract-declarator

.COMMENT The redundant spacing is needed to stop LaTex chopping characters off the end of some words and removing white space around keywords. The indentation has also been reduced. .E_COMMENT

direct-abstract-declarator: ( abstract-declarator ) direct-abstract-declarator opt [ assignment-expression opt ] direct-abstract-declarator opt [ type-qualifier-list opt assignment-expression opt ] direct-abstract-declarator opt [ static type-qualifier-list opt assignment-expression ] direct-abstract-declarator opt [ type-qualifier-list static assignment-expression ] direct-abstract-declaratoropt [ * ] direct-abstract-declaratoropt ( parameter-type-listopt )

1625 In several contexts, it is necessary to specify a type.

1626 This is accomplished using a type name, which is syntactically a declaration for a function or an object of that type that omits the identifier.126)

1627 EXAMPLE The constructions


        (a)        int
        (b)        int *
        (c)        int *[3]
        (d)        int (*)[3]
        (e)        int (*)[*]
        (f)        int *()
        (g)        int (*)(void)
        (h)        int (*const [])(unsigned int, ...)

name respectively the types (a) int, (b) pointer to int, (c) array of three pointers to int, (d) pointer to an array of three ints, (e) pointer to a variable length array of an unspecified number of ints, (f) function with no parameter specification returning a pointer to int, (g) pointer to function with no parameters returning an int, and (h) 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.

1628 126) As indicated by the syntax, empty parentheses in a type name are interpreted as “function with no parameter specification”, rather than redundant parentheses around the omitted identifier.

Next

Created at: 2008-01-30 02:39:44 The text from WG14/N1256 is copyright © ISO