Calling Dll (C++)


mrvin

Recommended Posts

Posted

Hello,

I am trying to call a DLL written in C++ from DAQfactory Pro 5.87

my code is (in C++ routine):

__declspec(dllexport) long __cdecl SetVoltage(float fVoltage=-1000, long iChannel=-1)

{}

and I call it in DAQfactory with:

extern (dllpath,"long SetVoltage(float, long)","IRISSetVoltage", "cdecl")

result=IRISSetVoltage(2.5,1)

I don't get any error message, but the routine in DLL is not executed.

I see in dependancy walker (depend.exe) that routine names are mangled, how can I solve that?

Thanks!

Posted

To avoid C++ name mangling, wrap your code in an extern "C" block:

extern "C" {

// your code here

}

Only the exposed functions need to be in the extern block.

Archived

This topic is now archived and is closed to further replies.