Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Calling IVF DLL's from VBA

rskalgutkar
Beginner
740 Views
I am in the process of migrating from CVF to IVF 8.0. DLL's that I wrote in CVF have problems when called from VBAafter I recompile in IVF. VBA complains about bad calling conventions. So I set the !dec$ attributes toSTDCALL andREFERENCE with no luck. Once I set the/iface to CVF via Project Properties and removed the STDCALL, REFERENCE attributes everything worked just fine.
My question: what is the difference between CVF and STDCALL, REFERENCE? Doesn't VBA use STDCALL as its calling convention and parameter passing by references?
Thanks.
0 Kudos
4 Replies
Steven_L_Intel1
Employee
740 Views
"CVF" implies ALL the defaults of CVF - STDCALL, pass by reference, uppercase names, string lengths mixed. If you say just STDCALL, you get pass by value and lowercase names (and string lengths at the end.)
Yes, you should use STDCALL (with appropriate modifiers) with VBA. I suggest avoiding the "CVF" switch - some bugs give it unwanted side effects.
0 Kudos
rskalgutkar
Beginner
740 Views
Steve,
Thanks. I was able to create a DLL using !dec$ attributes stdcall,reference compiler directives and setting uppercase names and mixed string length arguments in the Project Properties box.
The documentation says that if stdcall and reference are set via a !dec$ directive for a routine, then mixed string length arguments are implicit so long as noargument is set to reference individually and on W32 systems, names are uppercase. Is this correct? Or alternately is there any way to set uppercase names and mixed string length arguments via a !dec$ directive?
I also have another question about what will happen if I set a !dec$ stdcall but the Project Properties areset to __cdecl? Does the !dec$ directive supersede the Project Properties selection or the other way araound?
Thanks.
0 Kudos
Steven_L_Intel1
Employee
740 Views
It says that mixed string lengths are implicit? That's wrong.
Directives always override compile options/project properties.
If you explicitly say STDCALL in a directive, names are lowercased. Unless you say REFERENCE, arguments are passed by value. The location of the string length is not changed. (There's the [NO]MIXED_STR_LEN_ARG attribute for that.)
0 Kudos
rskalgutkar
Beginner
740 Views

Steve,

I have misstated that mixed length arguments are implicit. Here's an excerpt from the Intel Fortran Language Reference (14-12).

"If C or STDCALL is specified, and REFERENCE is specified for the routine (but REFERENCE is not specified for the argument, if any):

On all systems, the string is passed with the length"

But that's not the same implicit, so mea culpa. Thanks.

0 Kudos
Reply