prev up next   top/contents search

comp.lang.c FAQ list · Question 20.25

Q: How can I call FORTRAN (C++, BASIC, Pascal, Ada, LISP) functions from C? (And vice versa?)

A: The answer is entirely dependent on the machine and the specific calling sequences of the various compilers in use, and may not be possible at all. Read your compiler documentation very carefully; sometimes there is a ``mixed-language programming guide,'' although the techniques for passing arguments and ensuring correct run-time startup are often arcane. Besides arranging calling sequences correctly, you may also have to conspire between the various languages to get aggregate data structures declared compatibly.

For FORTRAN, more information may be found in FORT.gz by Glenn Geers, available via anonymous ftp from in the src directory. Burkhard Burow's header file cfortran.h simplifies C/FORTRAN interfacing on many popular machines. It is available via anonymous ftp from or at

In C++, a "C" modifier in an external function declaration indicates that the function is to be called using C calling conventions.

In Ada, you can use the Export and Convention pragmas, and types from the package Interfaces.C, to arrange for C-compatible calls, parameters, and data structures.

References: H&S Sec. 4.9.8 pp. 106-7

prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North