structs
, unions
and enums
are the constructed types. Their syntax is
presented in this section:
The identifier
in struct-type
defines a new legal type. Structure types
may also be named using a typedef declaration.
Name scoping rules require that the member declarators in a particular structure be unique.
Unions are a cross between the C union and switch statements. Unions must be
discriminated; that is, the union header must specify a typed tag field that
determines which union member to use for the current instance of a call. The
identifier
following the union keyword defines a new legal type. Union
types may also be named using a typedef declaration. The const_exp
in a
case_label
must be consistent with the switch_type_spec
. A default case
can appear at most once. The named-type
in the switch-type-spec
production must be a previously defined integer, char, boolean or enum type.
Case labels must match or be automatically castable to the defined type of
the discriminator. Name scoping rules require that the element declarators
in a particular union be unique. It is not required that all possible values
of the union discriminator be listed in the switch-body
.
Enumerated types consist of ordered lists of identifiers. The syntax is:
A maximum of 232 identifiers may be specified in an enumeration. The order
in which the identifiers are named in the specification of an enumeration
defines the relative order of the identifiers. The
identifier
following the enum keyword defines a new legal type. Enumerated
types may also be named using a typedef declaration.