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

/* next two statements depend on the automatic extended */
/* data segment being restored after the call to TAL */
sarr[1] = *s;
arr[1] = arr[0] + 5;
}
Interfacing to TNS COBOL
Your TNS C/C++ programs can call functions written in TNS COBOL. The general procedure
consists of these steps:
Use the TNS COBOL compiler (COBOL85 in the Guardian environment or cobol in the OSS
environment) to compile the COBOL function.
Use the TNS C/C++ compiler (named c) to compile the C/C++ program.
Use Binder to link the two object files and create the executable.
Example 3 shows the contents of an example TNS C program, named TESTC, that calls a COBOL
function.
Example 4: COBOL Function Called by a C Program shows the contents of the COBOL function,
named TESTCOB.
Example 5: Include File (Prototype Function) shows the contents of the header file used in this
example, named COBINCLH.
Example 6: Binder File shows the contents of the Binder file, named BINDIN.
Example 3 C Program that Calls a COBOL Function
/* TESTC */
#pragma inspect, symbols
#include <stdioh> nolist
#include "COBINCLH"
short main (void)
{
short ds;
long dl;
char *tx = "Displayed in COBOL.";
ds = 100;
dl = 40000;
XCOBFUNC (tx, &ds, &dl);
printf ("I'm Back in C and program is ending.\n");
}
For examples showing TNS/R native C calling a COBOL function in the Guardian and OSS
environments, see Interfacing to Native COBOL (page 140).
Interfacing to TNS COBOL 119