C# and libdivecomputer

Jef Driesen jef at libdivecomputer.org
Mon Dec 1 00:00:07 PST 2014


On 30-11-14 15:40, loicmichel wrote:
> I recomplied the DLL in visual studio  from the source code  (see enclosed) and
> now  the DLL load in my C# project but I get an other error.  Signature of the
> call doesn't match the signature of the function in the DLL.

I suspect this is due to the calling convention. Unless you changed it, the 
libdivecomputer dll is compiled with cdecl. But the Win32 API uses stdcall as 
the default calling convention, and so does .NET.

The solution is to specify the calling convention explicitly in the DllImport 
statements. Change all occurrences of:

[DllImport("libdivecomputer-0.dll")]

into this:

[DllImport("libdivecomputer-0.dll",CallingConvention=CallingConvention.Cdecl)]

> Could you send me the technical documentation of the VEO2 communication protocol
> ?  (it's only serial com )  I think I should start from there...

There is almost no documentation other than the libdivecomputer source code. Why 
do you need it?

Jef


More information about the devel mailing list