Fortran/C Calling Conventions

In C and Visual C++ modules, you can specify the STDCALL calling convention by using the __stdcall keyword in a function prototype or definition. The __stdcall convention is also used by window procedures and API functions. As an example, the following C language prototype sets up a function call to a subroutine using the STDCALL calling convention:

  extern void __stdcall FORTRAN_ROUTINE (int n);

Alternatively, instead of changing the calling convention of the C code, you can adjust the Fortran source code by using the C option. This is set with the ATTRIBUTES directive. For example, the following declaration assumes the subroutine is called with the C calling convention:

  SUBROUTINE CALLED_FROM_C (A)
     !DEC$ ATTRIBUTES C :: CALLED_FROM_C
     INTEGER A