HP C A.06.05 Reference Manual

Data Types and Declarations
Initialization
Chapter 3 63
Initialization
An initializer is the part of a declaration that provides the initial values for the objects being
declared.
Syntax
initializer
::=
assignment-expression
{
initializer-list
}
{
initializer-list
, }
initializer-list
::=
initializer
initializer-list , initializer
Description
A declarator may include an initializer that specifies the initial value for the object whose
identifier is being declared.
Objects with static storage duration are initialized at load time. Objects with automatic
storage duration are initialized at run-time when entering the block that contains the
definition of the object. An initialization of such an object is similar to an assignment
statement.
You can initialize a static object with a constant expression. You can initialize a static
pointer with the address of any previously declared object of the appropriate type plus or
minus a constant.
You can initialize an auto scalar object with an expression. The expression is evaluated at
run-time, and the resulting value is used to initialize the object.
When initializing a scalar type, you may optionally enclose the initializer in braces. However,
they are normally omitted. For example
int i = {3};
is normally specified as
int i = 3;