Overview of data declarations and definitions

A declaration establishes the names and characteristics of data objects used in a program. A definition allocates storage for data objects, and associates an identifier with that object. When you declare or define a type, no storage is allocated.

The following table shows examples of declarations and definitions. The identifiers declared in the first column do not allocate storage; they refer to a corresponding definition. The identifiers declared in the second column allocate storage; they are both declarations and definitions.

Declarations Declarations and definitions
extern double pi; double pi = 3.14159265;
struct payroll;
struct payroll {
                  char *name;
                  float salary;
               } employee;

Declarations determine the following properties of data objects and their identifiers:

The elements of a declaration for a data object are as follows:

IBM extension

In addition, ILE C/C++ allows you to use attributes to modify the properties of data objects. Type attributes, which can be used to modify the definition of user-defined types, are described in Type attributes. Variable attributes, which can be used to modify the declaration of variables, are described in Variable attributes.

End of IBM extension

All declarations have the form:

Read syntax diagramSkip visual syntax diagramData declaration syntax
 
   .-----------------------------.  .--------------------.
   V                             |  V                    |
>>---+-------------------------+-+----+----------------+-+------>
     '-storage_class_specifier-'      '-type_qualifier-'
 
                   .-,---------------------------.
                   V                             |
>--type_specifier----declarator--+-------------+-+--;----------><
                                 '-initializer-'
 

Related information



[ Top of Page | Previous Page | Next Page | Contents | Index ]