Microsoft KB Archive/38118

Problem Calling C Subroutine from COBOL with RM Directive

PSS ID Number: Q38118 Article last modified on 04-20-1993

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

Summary: If you perform an inter-language call to C from a COBOL program that has the RM or RM“ANSI” compiler directive, the C subroutine may do nothing or it may cause the computer to hang. The program will work correctly if the RM compiler directive is turned off (that is, NO RM). Microsoft has confirmed this to be a problem in COBOL versions 3.0 and 3.0a and Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2. We are researching this problem and will post new information here as it becomes available.

More Information: The compile and link steps below will produce an erroneous mixed-language program. If the “RM” directive is changed to “NO RM”, the program should run correctly. The steps are as follows: COBOL compile step: COBOL test.cbl /vsc2 rtncode-size(4) litlink rm; C compile step: CL /Awlf /c testc.c LINK step: LINK test+minitc+testc /noe; COBOL program “test.cbl”: PROCEDURE DIVISION. 000-MAIN. DISPLAY “In the COBOL program”. CALL “C_csub”. DISPLAY “Back in COBOL”. STOP RUN. C program “testc.c”: void csub { printf (“Now in the C program ”); }

Additional reference words: 3.00 3.00a 4.00 Copyright Microsoft Corporation 1993.