nld Utility
nld and noft Manual — 520384-003
2- 31
Declaration and Definition
Declaration and Definition
For data items shared across compilation units the difference between a declaration
and a definition is important.
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
Section 4, noft Utility
.
Definition:
The compiler allocates space for the data item, possibly giving it an
initial value.
Declaration:
A compilation unit recognizes a data item, so the code can refer to it,
but this compilation unit has not allocated space for it.
Table 2-7. Declarations and Definitions by Language
Language
Declarations
Definitions
C
C++
A data item is considered a
declaration if it is external and has no
initial value
Data items that are not external,
have initial values, or both
COBOL
No provision for declarations
All data items
pTAL
A data item is considered a
declaration if the compiler directive
EXPORT_GLOBALS
is set (this is the
default)
Data items defined when the
compiler directive
EXPORT_GLOBALS
is not set
Содержание nld
Страница 12: ...Contents nld and noft Manual 520384 003 x ...
Страница 16: ...What s New in This Manual nld and noft Manual 520384 003 xiv Miscellaneous ...
Страница 22: ...About This Manual nld and noft Manual 520384 003 xx Change Bar Notation ...
Страница 28: ...Introduction to the Utilities nld and noft Manual 520384 003 1 6 strip ...
Страница 60: ...nld Utility nld and noft Manual 520384 003 2 32 Declaration and Definition ...
Страница 78: ...nld Options nld and noft Manual 520384 003 3 18 y ...
Страница 90: ...noft Utility nld and noft Manual 520384 003 4 12 Debugging With noft ...
Страница 150: ...strip Utility nld and noft Manual 520384 003 7 2 ...
Страница 160: ...Converting From Binder to nld and noft nld and noft Manual 520384 003 9 8 Comparing Binder Commands to noft Options ...
Страница 242: ...nld Diagnostic Messages nld and noft Manual 520384 003 10 82 Informational Messages ...
Страница 278: ...noft Diagnostic Messages nld and noft Manual 520384 003 11 36 Syntax Errors ...
Страница 286: ...ar Diagnostic Messages nld and noft Manual 520384 003 12 8 ...
Страница 314: ...Sample nld and noft Session nld and noft Manual 520384 003 A 28 LISTSRLFIXUPS ...
Страница 330: ...Index nld and noft Manual 520384 003 Index 10 Special Characters ...