Problem:
C and COBOL, 32bit, mixed language application interface examples
Resolution:
C calling COBOL
-------------------
The COBOL program must be completed first to provide an import library needed to complete the C program. Use the CASE compiler directive. This will preserve the mixed case function names. Specify call-convention 74. This is a Windows 95/NT Standard call. It corresponds to APIENTRY. A call-convention specified in the procedure division header applies equally to each entry statement in the procedure division.
C integer items are 32bits, pic xxxx usage comp-5. C character strings are null terminated, z'STRING' or 'STRING' & x'00'. Numeric values, integers and longs, are passed/received by value. Character strings and records (structures) are passed/received by reference.
Compile and link the COBOL program from the command line as follows:
cbllink -v -k -l -d -FS C2CBLDLL.CBL
The -v switch is verbose, you'll see what is happenning displayed on the screen. This output can be redirected to a text file. The -k switch "keeps" files that are normally deleted, one of which is the import library for the Dll that is being created. The -l switch creates a map file. The -d switch creates a Dll.
The header file for the 'C' program, c2cblexe.h, must be modified to prototype the functions in the COBOL Dll. The import library for the COBOL program, c2cbldll.lib, must be added to the 'C' project link options. With all that accomplished you can then create the 'C' program.
Two additional COBOL programs, DYCBLEXE.CBL and STCBLEXE.CBL, and a Batch
file, DOC2CBL.BAT, are included below to illustrate how the COBOL Dll can be
called from a COBOL program and how to compile and link the COBOL programs.
COBOL calling C
--------------------
The C program must be completed first to provide an import library needed to complete the COBOL program. Compile and link the COBOL program from the command line as follows:
cbllink -v -l -k -BSF STCCBL2C.CBL CBL2CDLL.LIB
An additional COBOL program, DYNCBL2C.CBL, and a Batch file, DOCBL2C.BAT, are
included to illustrate how the 'C' Dll can be called dynamically from a COBOL program and how to compile and link the COBOL programs.
==========================================================
Keywords: Example, sample, demo, demonstration, mixed language, cncbl32b.zip
demo.ex
demo.ne