C/C++ Programmer's Guide (G06.25+)

Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
8-16
Considerations When Interfacing to pTAL
name x;
int i; extern short i;
int j; extern short j;
int k [0:2] = 'P' := [0, 1, 2]; extern const short k [3] := {0, 1, 2};
block b;
int .ext p; extern short* p;
int .ext s (template); extern Template s;
end block;
block c;
struct s1 (template); extern Template s1
int a [0:1]; extern short a [2];
end block;
If you want variable definitions to be in the C++ source, remove the extern specifier
and change the pTAL source to ?NOEXPORTGLOBALS.
In addition, if ?BLOCKGLOBALS is in effect and a data block contains one data
declaring item, the name exported to C/C++ is the name of the block. This method
makes it easy to change the name of a global declaration which cannot be described in
C/C++ to a legal C/C++ name. With this method, you do not need to change all uses of
the global declaration in the pTAL source. For pTAL programs, P-relative arrays
allocate space in the read-only data area of process memory space. For example:
pTAL Code C/C++ Code
?BLOCKGLOBALS
?EXPORTGLOBALS
name x;
block b;
int i^1; extern short b;
end block;
block c;
int .i [0:9]; extern short c [10];
end block;
block d;
int j = 'P' := [1, 2, 3]; extern short d [3] := {1, 2, 3};
end block;
block b1;
/* Names are not changed because there */
/* is more than one data declaring item */
/* in the block. */
int k; extern short k;
int l; extern short l;
end block;
block b2;
/* Names are not changed because there */
/* is more than one data declaring item */
/* in the block. */
int .m [0:9]; extern short m [0:9];
int n; extern short n;
end block;
block b3;
/* Names are not changed because there */