Fortran and C/C++ Hybrid Programming
To ensure successful linking, add an underscore (_) to the names of the global variables and functions in the C code that exchange information in hybrid programming, or use the compilation option -fno-underscoring. Otherwise, a linking error is reported.
Example code:
Fortran main program:
program test
external ctest
ii=20
x=200.0
call ctest(ii,x) // Call the C function interface.
end
C code:
void ctest_(int *ii,float *x) {
// Implementation
}
Parent topic: Common Problems (Syntax Differences)