Microsoft KB Archive/62834

COBOL Must Statically Link ADIS When Calling C

PSS ID Number: Q62834 Article last modified on 06-12-1990

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: If a SCREEN SECTION is used in a COBOL program that calls a C program, ADIS, ADISINIT, and ADISKEY must be statically linked for the program to run properly. If ADIS is dynamically linked, the program will hang, even if it is run from the directory where ADIS is located. This information on mixed-language programming applies to Microsoft COBOL versions 3.00 and 3.00a, and to Microsoft C version 5.10 for MS-DOS and MS OS/2. For more information on mixed-language programming with COBOL, search in the Software/Data Library (or in this Knowledge Base) for the following word: COBMIXED

More Information: The following is a code example:

COBOL Program
IDENTIFICATION DIVISION. PROGRAM-ID. COBTEST. DATA DIVISION. WORKING-STORAGE SECTION. 01 PASS-DATA. 03 PARM1       PIC X(10). 03 FILLER      PIC XX VALUE X&quot;00&quot;. SCREEN SECTION. 01 MAIN-SCREEN. 03 BLANK SCREEN. PROCEDURE DIVISION. MOVE &quot;HELLO&quot; TO PARM1. DISPLAY &quot;CALLING C NOW...&quot;. CALL &quot;C_ROUTINE&quot; USING PASS-DATA. DISPLAY &quot;BACK FROM C.&quot;. STOP RUN. Compile the above program as follows:

COBOL COBTEST.COB ;

C Program

 * 1) include  void routine (char far *p1) { printf (“from COBOL: %s”, p1); } Compile the above program as follows:

cl /c /Awlf cprog.c ; Using the following LINK line will hang the computer: link /noe cobtest minitc cprog,,,lcobol llibce ; The correct LINK command line to LINK the above COBOL and C routines is as follows: link /noe cobtest adis adisinit adiskey minitc cprog,,,lcobol llibce;

Copyright Microsoft Corporation 1990.