4.2 Initialization

Initializers provide an initial value for objects, and follow this syntax:

initializer:

   expression
   { initializer-list }
   { initializer-list, }

initializer-list:

   initializer
   initializer-list, initializer

Initialization of objects of each type is discussed in the following sections, but a few universal constraints apply to all initializations in C:

C has historically allowed initializers to be optionally surrounded by extra braces (to improve formatting clarity, for instance). These initializers are parsed differently depending on the type of parser used. DEC C uses the parsing technique specified by the ANSI standard, known as the top-down parse. Programs depending on a bottom-up parse of partially braced initializers can yield unexpected results. The compiler generates a warning message when it encounters unnecessary braces in common C compatibility mode or when the error-checking compiler option is specified on the command line.


Previous Page | Next Page | Table of Contents | Index