pTAL Reference Manual (H06.08+)
Compiling and Linking pTAL Programs
HP pTAL Reference Manual—523746-006
16-13
Declaring Global Data
Topics:
•
Naming Compilation Units on page 16-13
•
Declaring Named Data Blocks on page 16-13
•
Declaring Private Data Blocks on page 16-14
•
Declaring Unblocked Data on page 16-14
Naming Compilation Units
To assign an identifier to a compilation unit, specify the NAME declaration as the first
declaration in the compilation unit. (If no BLOCK declaration appears in the compilation
unit, you need not include the NAME declaration.) In the NAME declaration, specify
an identifier that is unique among all BLOCK and NAME declarations in the target file.
Declaring Named Data Blocks
A named data block is a global data block that is shareable among all compilation units
in a program. You can include any number of named data blocks in a compilation unit.
To declare a named data block:
•
Put a NAME declaration in the compilation (see Naming Compilation Units on
page 16-13).
•
Specify an identifier in the BLOCK declaration that is unique among all BLOCK and
NAME declarations in the target file.
A variable declared in a named data block can have the same name as the data block.
Modules written in pTAL can share global variables with modules written in HP C by
placing each shared variable in its own block and giving the variable and the block the
same name.
Example 16-2. Naming a Compilation Unit
NAME input_module; ! Name the compilation unit
Example 16-3. Declaring a Named Data Block
BLOCK globals; ! Declare named data block
INT .vol_array[0:7]; ! Declare global data
INT .out_array[0:34];
DEFINE xaddr = INT(32)#;
END BLOCK;
Example 16-4. Data Block and Variable With the Same Name
BLOCK c_var;
INT c_var;
END BLOCK;










