C/C++ Programmer's Guide (G06.25+)

Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
8-26
Interfacing to Native COBOL
For more information on using extended data segments, refer to the “Managing
Memory” section in the Guardian Programmer’s Guide.
Interfacing to Native COBOL
Your native C/C++ programs can call functions written in native COBOL.
The general procedure consists of the following steps: Use a native COBOL compiler
to compile the COBOL function. Use a native C/C++ compiler to compile the C/C++
program. Then use eld, ld, or nld to link the object files and create the executable.
Example 8-1, Example 8-2, and Example 8-3 show the contents of three files: a C
program, a COBOL program, and a header file, as follows:
In the example files shown on the following pages, file names appear as the OSS
versions. Of course, if you are working in the Guardian environment, the file names
would be the Guardian versions.
For examples of using TNS C to call TNS COBOL, see Interfacing to TNS COBOL on
page 7-30.
File Type OSS Name Guardian Name
C program testc.c testc
COBOL program testcob.cob testcob
Header or include file containing
prototype function
cobincl.h cobincl