Declaration And Definition; Example; Table 2-7. Declarations And Definitions By Language - HP nld Manual

Table of Contents

Advertisement

nld Utility

Declaration and Definition

For data items shared across compilation units the difference between a declaration
and a definition is important.
Definition:
Declaration:

Table 2-7. Declarations and Definitions by Language

Language
C
C++
COBOL
pTAL
Except for data that is exported from a user library, every data item must be defined at
least once when nld is building a loadfile. (If a data item is supposed to come from an
SRL, then it must not be defined within the program using the SRL.) If a data item is
never defined, you will get a run-time error when you execute your program. If you get
such an error, change your pTAL, C, or C++ source code so the data item is defined in
one of your compilation units. For example, you might need to provide a definition in
one of your C compilation units, or use the EXPORT_GLOBALS directive for your pTAL
compilation.
Data items defined in multiple COBOL or pTAL compilation units can be initialized
more than once, but all initial values for the same data item must be the same. Only
one C compilation unit is allowed to initialize a given data item.
nld does not perform type checking of symbols shared across compilation units.
When a data item is defined more than once, nld checks only that the size is the
same in all the definitions.
The body of a procedure is its definition and only one copy of that body can exist. It is
acceptable, however, for a body to be absent (the same is true for data, which—like
procedures—can be found in SRLs). If the body does not exist, the operating system
searches for the procedure at run time in the system library or a user library.
You can use the noft utility to examine symbol declarations and definitions in object
files. For more information on the noft utility, see
The compiler allocates space for the data item, possibly giving it an
initial value.
A compilation unit recognizes a data item, so the code can refer to it,
but this compilation unit has not allocated space for it.
Declarations
A data item is considered a
declaration if it is external and has no
initial value
No provision for declarations
A data item is considered a
declaration if the compiler directive
EXPORT_GLOBALS is set (this is the
default)
nld and noft Manual—520384-003
Definitions
Data items that are not external,
have initial values, or both
All data items
Data items defined when the
compiler directive EXPORT_GLOBALS
is not set
Section 4, noft
2- 31
Declaration and Definition
Utility.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Noft

Table of Contents