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

Table Of Contents
Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
8-19
Considerations When Interfacing to pTAL
In pTAL, pass structures by reference.
In C, use the & (ampersand) operator.
In pTAL, a routine cannot return a structure as a return value or pass a struct or
union by value.
This pTAL and C structures have compatible layouts:
pTAL Code C Code
STRUCT rec (
*
); struct birdname
BEGIN {
INT x; short x;
STRING y[0:2]; char y[3];
END; } robin[10];
STRUCT .EXT robin(rec)[0:9];
This pTAL and C structures have compatible layouts:
pTAL Code C Code
STRUCT rec1 (
*
); struct rec1
BEGIN {
STRING a, b, c; char a, b, c;
END; };
This pTAL and C structures also have compatible layouts:
pTAL Code C Code
STRUCT rec2 (
*
); struct rec2
BEGIN {
STRING e; char e;
INT y; short y;
STRING g; char g;
END; };
Multidimensional Arrays
In C, you can declare multidimensional arrays. In pTAL, you can emulate
multidimensional arrays by declaring structures that contain arrays.
Here is an example of multidimensional arrays in pTAL and native C:
pTAL Code C Code
STRUCT rec1 (
*
);
BEGIN
INT y[0:4]; short cma[10][5];
END;
STRUCT .EXT tma(rec1)[0:9];
!Sample access! /* sample access */
tma[8].y[3] := 100; cma[8][3] = 100;