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

How to make a IVF-based DLL to be called by VC++ via STDCALL?

Intel_C_Intel
Employee
518 Views

By default, IVF will generate a DLL to be called by VC++ through _cdecl. How to make a IVF DLL to be called by VC++ by STDCALL?

I have already changed calling convention within VC compiler to be __stdcall (/Gz). I tried the following simple code but got warning like[ warning C4007: 'main' : must be '__cdecl' ].

Thanks...

//FORTRAN PART

Subroutine MYDLL(t)
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL:: MYDLL

integer::t

t=t+2;

return

End Subroutine

//VC PART

#include "stdafx.h"

extern "C" void __stdcall mydll(int *intg);

void main()
{
int intg = 2 ;

mydll(&intg);

}

0 Kudos
1 Reply
Steven_L_Intel1
Employee
518 Views
You don't need the /Gz as you put __stdcall in the declaration for "mydll". The only thing you need to do is add the REFERENCE attribute to the !DEC$ ATTRIBUTES line, as STDCALL changes the passing mechanism to VALUE.

Make sure that the C code is built with the same run-time library option (/MD) as the DLL is (defaults to /MD or /libs:dll). If you are building in Visual Studio, use /MDd for a debug configuration.
0 Kudos
Reply