Calling Fortran functions from C in MSVC++5?
Posted on 1997-12-07
I was wondering what kind of settings and specifics are needed to setup in order to call Fortran functions from C code and vice versa. I have Visual Fortran from DEC and MSVC++5.0.
I have determined how to call C functions from Fortran code, by changing the Fortran settings to place an underscore at the end of the fortran function names, and to use all lower case. (Our C functions are all like 'void function_(...) )
The problem comes when I want to go the other way; calling Fortran functions from C. I noticed in some of the online-help that in __cdecl calling convention, the name of the C function stays the same, but when compiling the Fortran code, I get unresolved linker errors of _function_@12 could not be resolved.
This leads me to think I need to use the __stdcall calling convention, as this adds the @12 to the end of the functions, which is the same that the default Fortran compiler does. Is this the way I need to go? I'm just wondering then if I'll run into other problems using __stdcall....
I just would like to know the standard way of how people do the Fortran/C thing.