gfortran, DLL, underscore

前端 未结 4 1473
我在风中等你
我在风中等你 2021-01-25 14:35

I want to access some subroutines from a third party DLL. The functions use STDCALL as the calling convention.

Running dumpbin /export foo.dll gives me some

4条回答
  •  执笔经年
    2021-01-25 15:04

    You need to combine the use of ISO_C_BINDING with compiler attributes. You should really read the Mixed-Language Programming section of the gfortran manual. It gives good advice that can be used with other compilers as well. In particular, in your case you need the stdcall attribute:

    interface VisBasSubs
    
       subroutine foo (DoubleArg)  bind (C, name="Foo")
          !GCC$ ATTRIBUTES stdcall :: foo
          use iso_c_binding, only: c_double
          real (kind=c_double), intent (inout) :: DoubleArg      
    
       end subroutine foo
    
    end interface VisBasSubs
    

    Notice the line with stdcall, it's what should make it work.

提交回复
热议问题