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

If variable definitions are desired to be in the C++ source, remove the extern specifier and
change the pTAL source to ?NOEXPORTGLOBALS.
Parameters and Variables
This subsection provides guidelines for declaring compatible pTAL and C variables and parameters.
These guidelines supplement those given in Sharing Data (page 130). The topics discussed are:
STRING and char Variables
Arrays (page 134)
Structures (page 135)
Multidimensional Arrays (page 135)
Arrays of Structures (page 136)
Redefinitions and Unions (page 136)
Pointers (page 136)
Enumeration Variables (page 137)
pTAL Routines as Parameters to C (page 138)
C Routines as Parameters to pTAL (page 138)
STRING and char Variables
pTAL STRING and C char simple variables each occupies one byte of a word. Share variables of
type pTAL STRING and C char by using pointers or declare both as int.
Arrays
pTAL and C arrays differ:
C ArraypTAL ArrayCharacteristic
Always zeroAny integerLower bound
One or more dimensionsOne dimension *Dimensions
Indirect onlyDirect or indirectDirect or indirect
Native C and C++ only have byte
addressing
STRING arrays and extended indirect
arrays are byte addressed; all other
arrays are word addressed
Byte or word addressing
* pTAL structures can emulate multidimensional C arrays, as discussed in Multidimensional Arrays (page 135).
To declare compatible pTAL and C arrays:
Use data types and alignments that satisfy both compilers.
Declare pTAL arrays that have a lower bound of 0.
Declare one-dimensional C arrays.
Declare indirect pTAL arrays.
These are compatible arrays in pTAL and native C:
pTAL Code C Code
INT .EXT robin[0:9]; short robin [10];
INT(32) .EXT gull[0:14]; long gull [15];
STRING .EXT grebe[0:9]; char grebe [10];
134 Mixed-Language Programming for TNS/R and TNS/E Native Programs