Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Call C API from Fortran

Matthaios_Antoninis
586 Views
hello,
I am using Visual Fortran Composer XE11 with Microsoft Visual Studio 2008. First of all, i would like to know if the FORTRAN compiler supports C calling convention.
My aim is to use the C API of an installed program called MOSEK through the fortran main code which i have already used through c++ code. I want to mention that for the running of this C code I have to set as header files "".h, which for sure I will need in the cooperation of 2 codes (C,Fortran). If this can not be done I wonder if it is possible to call a C program as a subroutine from Fortran code. thank you in advance.
hello,I am using Visual Fortran Composer XE11 with Microsoft Visual Studio 2008. First of all, i would like to know if the FORTRAN compiler supports C calling convention.My aim is to use the C API of an installed program called MOSEK through the fortran main code which i have already used through c++ code. I want to mention that for the running of this C code I have to set as header files "".h, which for sure I will need in the cooperation of 2 codes (C,Fortran). If this can not be done I wonder if it is possible to call a C program as a subroutine from Fortran code.
thank you in advance.
0 Kudos
2 Replies
TimP
Honored Contributor III
586 Views
ifort iso_c_binding supports cdecl, which has been "the" Microsoft C ABI for over 10 years, except possibly for Windows API access. There are examples of the latter supplied with the compiler.
It's always possible to write a C wrapper to call by cdecl, according to iso_c_binding (no C++ mangling) or otherwise, and use that to make a call via another calling convention. There are also examples including C++ symbol mangling.
0 Kudos
Steven_L_Intel1
Employee
586 Views
Intel Visual Fortran uses the C calling convention by default. It supports all of Fortran 2003's C Interoperability features, which I recommend you use. I started a series of blog posts on this - you can find the first episode here.
0 Kudos
Reply