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

4-8
Array Formats 1b and 1d: Bounded Direct Arrays.
---------------------------------------------------------------------------------------------
|||
| SPL | HP C/XL Equivalent |
|||
---------------------------------------------------------------------------------------------
|||
|||
| 1b. INTEGER ARRAY ABC(0:4)=DB; | short int ABC[5]; |
|||
| 1b. INTEGER ARRAY ABC(-3:4)=DB; | short int ABC_REF[8]; |
| | short int *ABC = &ABC_REF[3]; |
|||
| 1d. INTEGER ARRAY ABC(0:4)=DB:=0,1,2,3; | short int ABC[5]={0,1,2,3}; |
|||
| 1d. INTEGER ARRAY ABC(-3:4)=DB:=6,2,5; | short int ABC_REF[8]={6,2,5}; |
| | short int *ABC = &ABC_REF[3]; |
|||
---------------------------------------------------------------------------------------------
These are SPL "direct" arrays: the location labeled ABC refers directly
to cell zero of the array allocation.
Note that the examples above having a nonzero lower bound still require
an indirect solution, identical to the one used for indirect arrays.
Array Formats 2a, 4a, and 5: Unbounded Indirect Arrays.
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| | |
| 2a. INTEGER ARRAY A1(@)=DB; | short int *A1; |
| | |
| 4a. INTEGER ARRAY A2(@); | short int *A2; |
| | |
| 5. INTEGER ARRAY A3(*); | short int *A3; |
| | |
---------------------------------------------------------------------------------------------
These declarations are equivalent in SPL, and each defines an identifi-
er.
However none of them allocates space for the array data; only one 16-bit
word is allocated to be used as a data label referring to an indirect
array, that is, as a pointer to space allocated elsewhere. The address
contained in this pointer must be initialized by the program at run time.
Simple pointers in HP C/XL are equivalent to this type of declaration.