# 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:

- When a Fortran program calls a C function, the C function's formal arguments must be declared as pointers to the appropriate data type.

- When a C program calls a Fortran subprogram, each actual argument must be specified explicitly as a pointer.

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:

- By value, which passes the argument's value.

- By reference, which passes the address of the arguments. On systems based on IA-32 architecture, Fortran, C, and C++ use 4-byte addresses. On systems based on Intel® 64 architecture, these languages use 8-byte addresses.

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).

Parent topic: Platform Specifics

## See Also

Handling Fortran Array Pointers and Allocatable Arrays