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

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 (page 134).
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;
C Routines That You Cannot Call Directly
pTAL procedures cannot call a C routine that:
Passes a struct or union parameter by value
Returns a struct or union parameter by value
Uses C-style variable argument list (...)
Calling pTAL Routines From C Modules
A C module has full access to the C run-time library even if the C module does not contain the
main() routine, but the C module might need to explicitly initialize the C run time library.
When you code C modules that call pTAL routines:
Include an interface declaration or a function prototype and FUNCTION pragma for each
pTAL routine to be called.
If a called pTAL routine sets the condition code, include the talh header file.
If a called routine is a system procedure, include the cextdecs header file.
It is recommended that you declare an external routine by using a function prototype and
FUNCTION pragma instead of an interface declaration. For more details, see Using a Function
Prototype and a FUNCTION Pragma (page 123). In C, an interface declaration is comparable to
an EXTERNAL procedure declaration in pTAL. For more details, see Using an Interface Declaration
(page 123).
Considerations When Interfacing to pTAL 127