pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 323 Data Block and Variable With the Same Name
BLOCK c_var;
INT c_var;
END BLOCK;
Declaring Private Data Blocks
A private data block is a global data block that is shareable only among the procedures within a
compilation unit. You can include only one private data block in a compilation unit. The private
data block inherits the identifier you specify in the NAME declaration; therefore, the NAME
declarations in all compilations that you use to assemble an executable program must have unique
names. To declare a private global data block, specify the PRIVATE option of the BLOCK declaration.
Example 324 Declaring a Private Data Block
BLOCK PRIVATE; ! Declare private global data block
INT term_num; ! Declare global data
LITERAL msg_buf = 79;
END BLOCK;
Declaring Unblocked Data
Place all unblocked global declarations (those not contained in BLOCK declarations) before the
first BLOCK declaration. Unblocked declarations are relocatable and shareable among all
compilation units in a program. The linking name of the private data block is derived from the
NAME declaration.
Example 325 Declaring Unblocked Data
INT a;
INT .b[0:9];
INT .EXT c[0:14];
LITERAL limit = 32;
The compiler places unblocked data declarations in implicit primary data blocks, created as follows:
1. When you use named blocks, private blocks, or the BLOCKGLOBALS directive, each data
item becomes its own block. All the other unblocked data items are grouped into a block
named _GLOBAL and $_GLOBAL.
2. Each block so created is split into two blocks to separate “large” data from “small” data.
“Large” data means arrays or structures declared with “.” or “.EXT” notation. “Small” data is
everything else. When both blocks exist, the “large” data block has a $ in front of its name.
For example, if you have the following global data declarations:
INT x;
INT .y;
INT .z [0:113]
Variables x and y are placed in the block named _GLOBAL, and z is placed in the block named
$_GLOBAL.
Named data blocks are split the same way. For example:
BLOCK blk;
INT x;
INT .y;
INT .ext z [0:99];
END BLOCK;
Two data blocks are created. Variables x and y are placed in the block named BLK and z is
placed in the block named $BLK.
You can link object files compiled with and without template blocks with no loss of information.
364 Compiling and Linking pTAL Programs