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

Table Of Contents
Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
8-26
Interfacing to Native COBOL
data segments. There are two types of extended data segments: flat segments and
selectable segments. Selectable segments are a carryover from TNS system
architecture. They continue to be supported on native systems. However, programs
written for native systems should use flat segments.
The term “extended” has little significance in the context of native systems. The only
non-extended data segment in user address space is the user data segment of a TNS
process, and there are no non-extended data segments in a native process.
For more details on using extended data segments, see 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 these steps:
Use a native COBOL compiler to compile the COBOL function.
Use a native C/C++ compiler to compile the C/C++ program.
Use eld, ld, or nld to link the object files and create the executable.
Example 8-1 on page 8-27, Example 8-2 on page 8-28, and Example 8-3 on page 8-28
shows the contents of three files: a C program, a COBOL program, and a header file:
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 programs to call TNS COBOL functions, 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