Declaration for C++ calling COBOL


Sample C usage COBOL subroutine
#include <stdio.h>
extern "C" {void cobrtn (int);};

int main()
{
  int x,y;
  x=1;
  y=cobrtn(x);  /* x by value */
  printf("y=%i.",y);
}
IDENTIFICATION DIVISION.
PROGRAM-ID. COBRTN.
ENVIRONMENT DIVISION.
DATA DIVISION.
LINKAGE SECTION.
01 A PIC S9(9) USAGE IS BINARY.
01 B PIC S9(9) USAGE IS BINARY.

PROCEDURE DIVISION USING BY VALUE A
                   RETURNING B.
       COMPUTE B = A + 1
       GOBACK.
END PROGRAM COBRTN.