Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

Calling a Fortran function, who has a c-header as the interface

Hi Steve, hi all,

 

How can I call from Fortran a Fortran function, who has a C header as the interface (in a DLL)?

 

code within the dll:

 

C header:

extern "C" __declspec(dllimport) char*  _cdecl TRNSYSFUNCTIONS_mp_GETTRNSYSUSERLIBDIR(void);

#define getTrnsysUserLibDir                           TRNSYSFUNCTIONS_mp_GETTRNSYSUSERLIBDIR   

 

Fortranfunction:

! function getTrnsysUserLibDir: returns the location of the directory that contains Release versions of external DLLs.

Function getTrnsysUserLibDir()

 !dec$ attributes dllexport :: getTrnsysUserLibDir

 Use TrnsysData

 Character (len=maxPathLength) :: getTrnsysUserLibDir

 getTrnsysUserLibDir = TrnsysUserLibDir

End Function getTrnsysUserLibDir

 

In the dependency walker I can see this:

Ordinal: 170 (0x00A9), Hint: 169 (0x00AD), Function: TRNSYSFUNCTIONS_mp_GETTRNSYSUSERLIBDIR, Entry Point: 0x00A6CBA

 

Olaf

0 Kudos