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

array[2] := "B";
status := c_func (array);
array[1] := "B";
END;
A C-series TNS C module called by a TAL module has limited access to the C run-time library. If
the TNS C module needs full access to the C run-time library, you can either:
Modify the program to run in the CRE as described in this section.
Specify a C MAIN routine that calls the original TAL main routine.
In the TAL module, remove the MAIN keyword from the TAL main routine and remove any
calls to the INITIALIZER or ARMTRAP system procedure. The TAL module must also meet the
requirements of the C run-time environment.
TAL Code C Code
#include <stdioh> nolist
INT status := 0;
INT .EXT array[0:4]; _tal void TALMAIN ( void );
INT PROC cfunc (a) short CFUNC (short *num)
LANGUAGE C; {
INT .EXT a; printf("num B4=%d\n",*num);
EXTERNAL; num[0] = 10;
printf("num AF=%d\n",*num);
PROC talmain; return 1;
BEGIN }
array[2] := 2;
status := main () /* C MAIN routine */
cfunc (array); {
END; TALMAIN ();
}
Calling TAL Routines From TNS C Modules
A TNS C module has full access to the TNS C run-time library even if the C module does not contain
the main() routine.
When you code TNS C modules that call TAL routines:
Include an interface declaration for each TAL routine to be called, or a function prototype and
a FUNCTION pragma, as described in Using a Function Prototype and a FUNCTION Pragma
(page 123).
If a called TAL routine sets the condition code, include the talh header file.
If a called routine is a system procedure, include the cextdecs header file.
In C, interface declarations are comparable to EXTERNAL procedure declarations in TAL.
To specify an interface declaration in C, include:
The keyword _tal
The _variable or _extensible attribute, if any, of the TAL routine
The data type of the return value, if any, of the TAL routine
A routine identifier
A public name if the TAL identifier is not a valid C identifier
A parameter-type list or, if no parameters, the keyword void
For extended pointers in the parameter-type list, the keyword _far after the parameter type
104 Mixed-Language Programming for TNS Programs