Intel® Fortran Compiler 16.0 User and Reference Guide
By default, the Fortran compiler converts function and subprogram names to lower case for Linux* and OS X* and upper case for Windows*. The C compiler never performs case conversion. A C procedure called from a Fortran program must, therefore, be named using the appropriate case.
C++ uses the same calling convention and argument-passing techniques as C, but naming conventions differ because of C++ decoration of external symbols. When the C++ code resides in a .cpp file, C++ name decoration semantics are applied to external names, often resulting in linker errors. The extern "C" syntax makes it possible for a C++ module to share data and routines with other languages by causing C++ to drop name decoration.
The following example declares prn as an external function using the C naming convention. This declaration appears in C++ source code:
extern "C" { void prn(); }
To call functions written in Fortran, declare the function as you would in C and use a "C" linkage specification. For example, to call the Fortran function FACT from C++, declare it as follows:
extern "C" { int fact( int* n ); }
The extern "C" syntax can be used to adjust a call from C++ to other languages, or to change the naming convention of C++ routines called from other languages. However, extern "C" can only be used from within C++. If the C++ code does not use extern "C" and cannot be changed, you can call C++ routines only by determining the name decoration and generating it from the other language. Such an approach should only be used as a last resort, because the decoration scheme is not guaranteed to remain the same between versions.
When using extern "C" in a C++ program, keep in mind the following restrictions:
You cannot declare a member function with extern "C".
You can specify extern "C" for only one instance of an overloaded function; all other instances of an overloaded function have C++ linkage.