HP C/iX Reference Manual (31506-90011)

Chapter 3 27
Data Types and Declarations
Declarations
Declarations
A declaration specifies the attributes of an identifier or a set of identifiers.
Syntax
declaration
::=
declaration-specifiers [init-declarator-list]
;
declaration-specifiers
::=
storage-class-specifier [declaration-specifiers]
type-specifier [declaration-specifiers]
type-qualifier [declaration-specifiers]
init-declarator-list
::=
init-declarator
init-declarator-list
,
init-declarator
init-declarator
::=
declarator
declarator
=
initializer
Description
Making a declaration does not necessarily reserve storage for the identifiers declared. For
example, the declaration of an external data object provides the compiler with the
attributes of the object, but the actual storage is allocated in another translation unit.
A declaration consists of a sequence of specifiers that indicate the linkage, storage
duration, and the type of the entities that the declarators denote.
You can declare and initialize objects at the same time using the init-declarator-list syntax.
The init-declarator-list is a comma-separated sequence of declarators, each of which may
have an initializer.
Function definitions have a slightly different syntax as discussed in 'Function Declarators'
later in this chapter. Also, note that it is often valid to define a tag (struct, union,orenum)
without actually declaring any objects.
Examples
Valid Declarations:
extern int pressure [ ]; /* size will be declared elsewhere *
/
extern int lines = 66, pages; /* declares two variables,
initializes the first one *
/
static char private_func (float); /* a function taking a float,
returning a char, not known
outside this unit *
/