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-8
Considerations When Interfacing to pTAL
Incompatibilities between pTAL and C data types include:
pTAL has no numeric data type that is compatible with C unsigned long type.
pTAL UNSIGNED is not compatible with the C unsigned short type. pTAL
UNSIGNED(16), INT, or INT(16) can represent signed or unsigned values.
For more details on C and pTAL data types, see Parameters and Variables on
page 8-17.
Calling C Routines From pTAL Modules
A pTAL module must include an EXTERNAL procedure declaration for each C routine
to be called. This pTAL code shows the EXTERNAL procedure declaration for
C_FUNC and a routine that calls C_FUNC. ARRAY is declared with .EXT, because
C_FUNC uses the large-memory model:
pTAL Code C Code
INT status := 0; short C_FUNC(char *str)
STRING .EXT array[0:4]; {
*str = 'A';
INT PROC c_func (a) str[2] = 'C';
LANGUAGE C; return 1;
STRING .EXT a; }
EXTERNAL;
PROC example MAIN;
BEGIN
array[2] := "B";
status := c_func (array);
array[1] := "B";
END;
INT .i; INT short
*
INT (32) .j; INT(32) int
*
FIXED .f; FIXED(0) long long
*
REAL .r; REAL float
*
REAL(64) .s; REAL(64) double
*
Indirect using 32-bit pointers
STRING .EXT s; STRING char
*
INT .EXT i; INT short *
INT (32) .EXT j; INT(32) int
*
FIXED .EXT f; FIXED(0) long long
*
REAL .EXT r; REAL float
*
REAL(64) .EXT s; REAL(64) double
*
Table 8-1. Compatible pTAL and C Data Types (page 2 of 2)
pTAL Declaration pTAL Data Type C Data Type