The following summarizes how to reconcile names between languages:
If you call a Fortran routine that uses Fortran defaults and cannot recompile the Fortran code, then in C, you must use an all-uppercase name to make the call. Use of the __stdcall convention in C code is not enough, because __stdcall always preserves case in C. Fortran generates all-uppercase names by default and the C code must match it.
For example, this C prototype establishes the Fortran function FFARCTAN(angle)
where the argument angle has the ATTRIBUTES
VALUE property:
extern float __stdcall FFARCTAN( float angle );
If the name of the routine appears as all lowercase in C, then naming conventions are automatically correct when the C option is used in the Fortran declaration. Any case can be used in the Fortran source code, including mixed case, since the C option changes the name to all lowercase.
If the name of a routine appears as mixed-case in C and you cannot change the name, then you can resolve this naming conflict by using the Fortran ATTRIBUTES ALIAS option. ALIAS is required in this situation because otherwise Fortran will not preserve the mixed-case name.
To use the ALIAS option, place the name in quotation marks exactly
as it is to appear in the .o
file.
The following is an example for referring to the C function My_Proc
on IA-32 systems:
!DEC$ ATTRIBUTES ALIAS:'_My_Proc' :: My_Proc
On ItaniumŪ-based systems, the same example would be coded without
the leading underscore as:
!DEC$ ATTRIBUTES ALIAS:'My_Proc' :: My_Proc
To make this example work on both IA-32 and Itanium-based systems,
use the following:
!DEC$ ATTRIBUTES DECORATE,ALIAS:'My_Proc' :: My_Proc