C/C++ Programmer's Guide (G06.25+)
Mixed-Language Programming for TNS Programs
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
7-17
Variables and Parameters
In the following example, a TAL module declares a variable within a BLOCK
declaration, and the TNS C module declares the equivalent variable:
TAL Code C Code
NAME TAL_module;
BLOCK fred;
INT .EXT fred; int FRED; /*all uppercase*/
END BLOCK;
Because this method requires that the layout of the corresponding TAL and C
declarations match, it is recommended that you share data by using pointers where
possible.
Variables and Parameters
This subsection gives guidelines for declaring compatible TAL and C variables and
parameters. These guidelines supplement those given in the previous subsection,
Sharing TAL Data With TNS C Using BLOCK Declarations on page 7-16. The following
topics are discussed here:
•
STRING and char variables
•
Arrays
•
Structures
•
Multidimensional arrays
•
Arrays of structures
•
Redefinitions and unions
•
Pointers
•
Enumeration variables
•
Bit-field manipulation
•
UNSIGNED variables and packed bit fields
•
TAL routines as parameters to C
•
C routines as parameters to TAL
When you declare formal reference parameters, remember to use indirection as
follows:
•
If the caller is a small-memory-model TNS C routine, use standard indirection (.)
for the TAL formal parameter.
•
If the caller is a large-memory-model TNS C routine, use extended indirection
(.EXT) for the TAL formal parameter.
STRING and char Variables
TAL STRING and C char simple variables each occupy one byte of a word. Following
are STRING and char compatibility guidelines:
•
Share variables of type TAL STRING and C char by using pointers.