Example of declaration for C++ calling Fortran

The following example shows a partial C++ routine that calls a Fortran function. The calling C++ routine contains the extern "FORTRAN" linkage specification for the Fortran function FORTFCN, the function prototype for the Fortran function, and a static call to the Fortran function.


C++ routine Fortran function
extern "FORTRAN"
  {double fortfcn(int, double *);}
⋮
double fortfcn(int, double [100]);
⋮
int index;
double list[100];
double value;
⋮
value=fortfcn(index, list);
FUNCTION FORTFCN 
   (INDEX, LIST) RESULT (VALUE)
INTEGER*4 INDEX
REAL*8 LIST(0:99)
REAL*8 VALUE
⋮
VALUE=LIST(INDEX)
END