SPL to HP C/XL Migration Guide (30231-90001)

4-1
Chapter 4 Global Data Declarations
This chapter discusses conversion issues that correspond to sections in
Chapter 3 of the
Systems Programming Language Reference Manual
.
Types of Declarations
Table 4-1. Declaration Types
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| Global declarations occur in the global | Global declarations occur in the outer |
| declaration section, the first section of a | block, outside function definitions. |
| program or subprogram. | |
| | Besides occurring before the first function |
| | definition, as in SPL, global declarations |
| | may also occur
between
function |
| | definitions. |
| | |
---------------------------------------------------------------------------------------------
| | |
|
global-data-declaration
: |
global-data-declaration
: |
| | |
| [GLOBAL]
data-declaration
| [static]
data-declaration
|
| | |
---------------------------------------------------------------------------------------------
| | |
| Globally declared identifiers can be | As with SPL, global identifiers can be |
| accessed from all procedures (and the main | accessed by all functions that follow the |
| body) in the compilation unit. | declarations in the compilation unit. |
| | |
| | Unlike SPL, an identifier that should be |
| | known only within the compilation unit |
| | should be preceded by the static storage |
| | class specifier. |
| | |
---------------------------------------------------------------------------------------------
| | |
| If an identifier is preceded by the GLOBAL | All globally declared identifiers may be |
| storage attribute, it may also be | referenced from other compilation units. |
| referenced from a procedure in a different | In an external unit, a reference to the |
| compilation unit. In that external unit, | same identifier should be declared with the |
| the same identifier is declared in the | extern storage class specifier. |
| local declaration section of a procedure | |
| with the EXTERNAL storage attribute. | |
| | |
---------------------------------------------------------------------------------------------
| | |
| SPL also allows linking global identifiers | HP C/XL will match up global identifiers |
| between compilation units by the method of | that are declared in separate units. The |
| including matching global declarations in | identifiers
must be the same
in all units |
| both program and subprograms. All | The unneeded declarations may be deleted. |
| declarations must be present in the same | |
| order, including those for identifiers that | |
| are not used in the subprogram. The data | |
| types must match; the identifiers
may be
| |
|
different
. | |
| | |
---------------------------------------------------------------------------------------------