HP 3000 Manuals

Types of Declarations [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation


SPL to HP C/XL Migration Guide

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.                                  |                                             |
|                                             |                                             |
---------------------------------------------------------------------------------------------

SPL data declarations have only three general forms:  simple, array, and
pointer.  However, this simplicity is enhanced by the powerful ability to
equivalence data of all types and formats and to develop elaborate
overlay structures.

It is necessary, therefore, to understand the physical relationships
between data elements.  Much of that is beyond the scope of this guide.
However, it may be useful to you to construct a diagram of the DB-, Q-,
and S-relative data areas to determine the correct choice for converting
data declarations.

In many cases, you may be able to use HP C/XL pointers in simple
emulation of the SPL declarations.  In other cases, the data
relationships may require an HP C/XL union declaration to ensure the
correct interplay of the variables.

In the following sections, the SPL and HP C/XL type syntax elements refer
to the following simple variable types:

---------------------------------------------------------------------------------------------
|                                             |                                             |
|                     SPL                     |             HP C/XL Equivalent              |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| INTEGER                                     | short int                                   |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DOUBLE                                      | long int                                    |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| LOGICAL                                     | unsigned short int                          |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| BYTE                                        | unsigned char OR unsigned short int         |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| REAL                                        | float                                       |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| LONG                                        | double                                      |
|                                             |                                             |
---------------------------------------------------------------------------------------------

The rest of this chapter discusses global declarations.  Local and
external declarations are discussed in Chapter 8.



MPE/iX 5.0 Documentation