Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

What is proper syntax for DLL calls

Brian_Murphy
New Contributor II
427 Views
In fortran I have subroutine HSEALH_2010() !DEC$ ATTRIBUTES DLLEXPORT :: HSEALH_2010 I have been successful calling this from Excel visual basic if the subroutine has no arguments, but I can't get it to work with any arguments. Can someone give me an example or two of how to do this with arguments? Thanks, Brian in Austin, Texas
0 Kudos
2 Replies
Steven_L_Intel1
Employee
427 Views

You need STDCALL, REFERENCE and ALIAS:

!DEC$ ATTRIBUTES DLLEXPORT,STDCALL,REFERENCE,ALIAS:"HSEALH_2010" :: HSEALH_2010

STDCALL is needed because VB/VBA uses it. WIthout that, you can corrupt the stack if you have arguments. REFERENCE is needed to offset the default pass-by-value of STDCALL.  ALIAS is needed to set the name you'll use from VBA.

There is a worked example provided called, of all things, EXCEL, under MixedLanguage. I suggest you study it.

0 Kudos
Brian_Murphy
New Contributor II
427 Views
I see!, said the blind man. That was exactly what I needed, and it now works perfectly. Thanks for the tip about the EXCEL sample project. It shows how to pass a string to fortran and I didn't know how to do that. That will come in handy. Cheers, Brian
0 Kudos
Reply