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


Example of declaration for Fortran calling C++

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

The following example shows a partial Fortran routine that calls a C++ function. The called C++ function contains the extern "FORTRAN" linkage specification for the C++ function CFCN and the function definition for the C++ function.

Fortran routine C++ function
INTEGER*4 INDEX
REAL*8 LIST(0:99)
REAL*8 VALUE
REAL*8 CFCN
⋮
VALUE=CFCN(INDEX, LIST)
extern "FORTRAN" 
   {double cfcn(int *, double *);}
⋮
double cfcn(int *index, double list [])
{
⋮
return list[*index];
}

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014