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

Bad calling convention

Intel_C_Intel
Employee
1,477 Views
Hello,
I have some F77 code for a dll that was compiled by somebody else. I have the dll and the source code (but not the original compiler). The dll works fine with an Excel application.
I created a new DLL project in IVF 9.0 and added all those files and built the dll. When called from Excel, the functions in the dll execute fine, but on exit I keep getting the error 'Bad DLL Calling Convention'.
I tried changing the calling convention under project project properties but didnt help. What should be the correct convention ?
Thank you.
vikrantca
0 Kudos
7 Replies
Steven_L_Intel1
Employee
1,477 Views
You would want "Stdcall, reference" as the convention (or "CVF") for compatibility with Excel.
0 Kudos
Intel_C_Intel
Employee
1,477 Views
Right. I thought so too. But when I set it to STDCALL REFERENCE, but I still get the BAD DLL calling convention error.
Fortran Call :

subroutine SETUPdll(i,hfld,hfm,hrf,ierr,herr)

!DEC$ ATTRIBUTES DLLEXPORT::SETUPdll

!DEC$ATTRIBUTES ALIAS: 'SETUPdll'::SETUPdll

implicit double precision (a-h,o-z)

implicit integer (i-k,m,n)

c Previously the attribute was here

parameter (ncmax=20)

character hfld*10000,hfm*255,hrf*3,herr*255,hfmix*255

character*255 hf(ncmax)

......

END

Excel Call :

Public Declare Sub SETUPdll Lib "REFPFF" (i As Long, ByVal hfld As String, ByVal hfmix As String, ByVal hrf As String, ierr As Long, ByVal herr As String, ln1 As Long, ln2 As Long, ln3 As Long, ln4 As Long)

thanks.

vikrantca

0 Kudos
Steven_L_Intel1
Employee
1,477 Views
Hmm - make sure that the String Length Argument Passing is set to "after all arguments".
0 Kudos
Intel_C_Intel
Employee
1,477 Views
Thanks. Done that already. Still doesnt work.
I have the Code Generation option Generate Reentrant code set to yes. Does this have to do anything with the error ?
thanks
vikrantca
0 Kudos
Steven_L_Intel1
Employee
1,477 Views
No. I suggest you send your project and Excel code to Intel Premier Support and we'll take a look. Ask that it be assigned to Steve Lionel.
0 Kudos
Intel_C_Intel
Employee
1,477 Views
Is there a site where I can download a sample project for fortran dll that is called from VB/Excel ?
thanks
vikrantca
0 Kudos
Steven_L_Intel1
Employee
1,477 Views
Here's one.
0 Kudos
Reply