z/OS Language Environment Writing Interlanguage Communication Applications
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Structure with extern "COBOL"

z/OS Language Environment Writing Interlanguage Communication Applications
SA38-0684-00

Sample C++ usage COBOL subroutine
#include <stdio.h>
#include <stdlib.h>
struct stype {
  int s1;
  int s2;};
extern "COBOL" {void COBRTN
  (struct stype,struct stype*);}

int main()
{
  struct stype struc1,struc2;
  struc1.s1=1;
  struc1.s2=2;
  struc2.s1=3;
  struc2.s2=4;
  COBRTN(struc1,&struc2);
    /* struc1 by value */
    /* struc2 by reference */
  exit(0);
}
IDENTIFICATION DIVISION.
PROGRAM-ID. COBRTN.
ENVIRONMENT DIVISION.
DATA DIVISION.
LINKAGE SECTION.
01 STRUC1.
     05 S11 PIC S9(9) BINARY.
     05 S12 PIC S9(9) BINARY.
01 STRUC2.
     05 S21 PIC S9(9) BINARY.
     05 S22 PIC S9(9) BINARY.
PROCEDURE DIVISION USING STRUC1 STRUC2.
     DISPLAY S11 S12 S21 S22
     GOBACK.
END PROGRAM COBRTN.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014