TAL Programmer's Guide
TAL and C Guidelines
Mixed-Language Programming
17–12 096254 Tandem Computers Incorporated
Calling C Routines
From TAL Modules
A TAL module must include an EXTERNAL procedure declaration for each C routine
to be called. The following TAL 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:
TAL 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;
A C-series C module called by a TAL module has limited access to the C run-time
library. If the C module needs full access to the C run-time library, you can either:
Modify the program to run in the CRE as described later in this section.
Specify a C MAIN routine that calls the original TAL MAIN routine as follows.
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 ();
}