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

77 D-LARGE NATIVE-4.
PROCEDURE DIVISION USING D-STRING, D-SHORT, D-LARGE.
000-INIT.
DISPLAY "I AM DOING COBOL NOW".
COMPUTE D-RESULT = D-LARGE / D-SHORT.
DISPLAY "D-STRING = " D-STRING.
DISPLAY "D-LARGE = " D-LARGE.
DISPLAY "D-SHORT = " D-SHORT.
DISPLAY "D-RESULT = " D-RESULT.
DISPLAY "LEAVING COBOL PROGRAM NOW".
EXIT-PROGRAM.
Example 9 Include File (Prototype Function)
================================================================
The include file for OSS (cobincl.h)
================================================================
/* COBINCL */
void XCOBFUNC (char *, short *, long *);
#pragma FUNCTION XCOBFUNC (cobol)
Compiling and Linking the COBOL and C Programs
To compile the programs in the OSS environment:
1. Compile the COBOL function named testcob.cob using the TNS/R native COBOL compiler:
nmcobol -c testcob.cob
or compile the function using the TNS/E native COBOL compiler:
ecobol -c testcob.cob
2. Compile the C program named testc.c using c89 or c99 (TNS/E only):
c89 -c testc.c
The resulting object file is named testc.o.
3. Link the object files using the TNS/R native linker on a TNS/R system or eld on a TNS/E
system:
nld /usr/lib/crtlmain.o testc.o testcob.o -o test.exe -obey /
G/system/system/libcobey -l zcobsrl
or
eld /usr/lib/ccplmain.o testc.o testcob.o -o test.exe
-l zcobdll
4. Run the program:
./test.exe
To compile the programs in the Guardian environment:
1. Compile the COBOL function named testcob using the TNS/R native COBOL compiler:
nmcobol /in testcob / testcobo
or compile the function using the TNS/E native COBOL compiler:
ecobol /in testcob / testcobo
2. Compile the C program named testc using the TNS/R native C compiler:
nmc / in testc/ testco
or compile the function using the TNS/E native C compiler:
ccomp / in testc/ testco
3. Link the object files using TNS/R native linker on a TNS/R system or eld on a TNS/E system:
142 Mixed-Language Programming for TNS/R and TNS/E Native Programs