pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
compilation unit. If you include a BLOCK declaration in a compilation unit, you must assign an
identifier to the compilation unit by using a NAME declaration.
Unblocked global data declarations are those appearing outside a BLOCK declaration. Such
declarations are also relocatable and shareable among all compilation units in a program.
If you do not use the BLOCKGLOBALS directive, then all separate compilations must specify exactly
the same list of unblocked global data declarations.
If present in a compilation unit, global declarations must appear in the following order:
1. NAME declaration
2. Unblocked global data declarations
3. BLOCK declarations
4. PROC declarations
Topics:
• Naming Compilation Units (page 363)
• Declaring Named Data Blocks (page 363)
• Declaring Private Data Blocks (page 364)
• Declaring Unblocked Data (page 364)
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.
Example 321 Naming a Compilation Unit
NAME input_module; ! Name the compilation unit
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 (page 363)).
• Specify an identifier in the BLOCK declaration that is unique among all BLOCK and NAME
declarations in the target file.
Example 322 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;
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.
Compiling With Global Data Blocks 363