Intel® Fortran Compiler 16.0 User and Reference Guide

Passing Arguments in Mixed-Language Programming

By default, Fortran programs pass arguments by reference; that is, they pass a pointer to each actual argument rather than the value of the argument. C programs typically pass arguments by value. Consider the following:

You can pass data between Fortran and C/C++ using argument lists just as you can within each language (for example, the argument list a, b and c in CALL MYSUB(a,b,c)). There are two ways to pass individual arguments:

You need to make sure that for every call, the calling program and the called routine agree on how each argument is passed. Otherwise, the called routine receives bad data.

The Fortran technique for passing arguments changes depending on the calling convention specified. By default, Fortran passes all data by reference (except the hidden length argument of strings, which is passed by value).

On Windows* systems using IA-32 architecture only, you can alter the default calling convention. You can use either the /iface:stdcall option (stdcall) or the /iface:cvf option (Compaq* and Powerstation compatibility) to change the default calling convention, or the VALUE or C attributes in an explicit interface using the ATTRIBUTES directive. For more information on the ATTRIBUTES directive, see the Intel® Fortran Language Reference.

Both options cause the routine compiled and routines that it calls to have a @<n> appended to the external symbol name, where n is the number of bytes of all parameters. Both options assume that any routine called from a Fortran routine compiled this way will do its own stack cleanup, "callee pops." /iface:cvf also changes the way that CHARACTER variables are passed. With /iface:cvf, CHARACTER variables are passed as address/length pairs (that is, /iface:mixed_str_len_arg).

See Also