PhilBayley
Well-known member
Ummm - I am getting very annoyed at the mo with the c# rubbish. I am now trying to use callbacks to my c# application from my c++ dll. For various reasons I need the dll to be compiled using the __cdecl (/Gd) calling convention. I have my c# code as follows
[DllImport("mydll.dll", EntryPoint="SetAddresses", SetLastError=true, CharSet=CharSet.Ansi, ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
public static extern bool SetAddresses(PercentCallBack w,MessageCallBack x,MessageCallBack y, FinishedCallBack z);
This in theory should work as both the dll and the function are set to cdecl. The only way I can get this to work is to compile the c++ dll in __stdcall (/Gz). It doesnt seem to matter about the c# code as it seems to ignore the calling convention bit anyway.
HELP! - I need to do it using __cdecl.
PhilBayley
[DllImport("mydll.dll", EntryPoint="SetAddresses", SetLastError=true, CharSet=CharSet.Ansi, ExactSpelling=true, CallingConvention=CallingConvention.Cdecl)]
public static extern bool SetAddresses(PercentCallBack w,MessageCallBack x,MessageCallBack y, FinishedCallBack z);
This in theory should work as both the dll and the function are set to cdecl. The only way I can get this to work is to compile the c++ dll in __stdcall (/Gz). It doesnt seem to matter about the c# code as it seems to ignore the calling convention bit anyway.
HELP! - I need to do it using __cdecl.
PhilBayley