C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
Mixed-Language Programming for TNS Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
7-24
Variables and Parameters
If the WIDE pragma is not specified, the TNS C compiler normally packs adjacent bit
fields in a 16-bit word. If the WIDE pragma is specified, the TNS C compiler normally
packs adjacent bit fields in a 32-bit word.
TAL UNSIGNED(1–16) and C bit fields of like size are compatible. TAL
UNSIGNED(17–31) and C bit fields of like size are compatible.
The TAL compiler always packs adjacent UNSIGNED simple variables in 16-bit words:
It starts the first UNSIGNED variable on a word boundary.
It packs each successive UNSIGNED variable in the remaining bits of the same
word as the preceding UNSIGNED variable if:
°
The variable contains 1 to 16 bits and fits in the same word
°
The variable contains 17 to 31 bits and fits in the same word plus the next word
If an UNSIGNED variable does not fit in the same word or double word, the
compiler starts the variable on the next word boundary.
The operator you use determines whether UNSIGNED values are signed or unsigned:
UNSIGNED(3) x; !TAL code
UNSIGNED(3) y;
IF x + y ... ; !Signed operation
IF x '+' y ... ; !Unsigned operation
UNSIGNED arrays that contain 8-bit or 16-bit elements are compatible with C arrays
that contain elements of like size. UNSIGNED arrays that contain 1-bit, 2-bit, or 4-bit
elements are incompatible with C arrays.
TAL Routines as Parameters to TNS C
You can call TNS C routines and pass TAL routines as parameters. You can pass any
TAL routine except EXTENSIBLE or VARIABLE routines as parameters.
A passed TAL routine can access the routine’s local variables and global TAL
variables. The passed routine can contain subprocedures, but they cannot be passed
as parameters.
If you call a large-memory-module TNS C routine, the EXTERNAL procedure
declaration for the TNS C routine must specify the PROC(32) parameter type in the
parameter declaration. When you pass the PROC(32) parameter to the TNS C routine,
the compiler passes a 32-bit address that contains PEP and map information in the
high-order word and a zero in the low-order word.
If you call a small-memory-module TNS C routine, the EXTERNAL procedure
declaration for the TNS C routine must specify the PROC parameter type in the
parameter declaration. When you pass the PROC parameter to the TNS C routine, the
compiler passes a 16-bit address that contains PEP and map information.