LF Fortran 95

Declaring Calling Conventions

In order to reference a procedure across a DLL interface, the LF95 compiler must be informed of the procedure name to be exported, and given a calling convention for the external names in your DLL.

The procedure names that will be externally available are defined with the DLL_EXPORT and DLL_IMPORT statements in the source code. Please note that procedure names appearing in a DLL_EXPORT or DLL_IMPORT statement are case sensitive (unlike the Fortran naming convention, which ignores case).

DLL_EXPORT is used to define an externally available DLL procedure.

DLL_IMPORT is used when referencing a DLL procedure.

The calling convention is defined with the use of the -ML compiler option. You cannot mix -ml options in a single invocation of LF95. If you need to reference DLLs from multiple languages you can do so by putting the references in separate source files and compiling them separately.

 

-ML Options

Option

Compiler

-ml lf95

LF Fortran 95

-ml lf90

Lahey Fortran 90

-ml bc

Borland C++

-ml bd

Borland Delphi

-ml msvc

Microsoft Visual C++

-ml msvb

Microsoft Visual Basic

-ml winapi

Windows API functions invoked directly from Fortran

LF95 can build DLLs callable from Microsoft Visual Basic, however, Microsoft Visual Basic does not build DLLs callable by LF95. Assembly procedures may be called from Fortran procedures, however the use of DOS interrupts is not supported.

See Also

DLL_IMPORT Statement

DLL_EXPORT Statement