开发者

C# equivalent for C++ "signed long int"

开发者 https://www.devze.com 2023-02-19 17:48 出处:网络
I import a C++ dll into a C# project and, on a x64 machine, on debug mode, PInvoke complains that m开发者_运维问答anaged signature does not match the unmanaged target signature.

I import a C++ dll into a C# project and, on a x64 machine, on debug mode, PInvoke complains that m开发者_运维问答anaged signature does not match the unmanaged target signature.

C++:

void _Foo(signed long int x);

C#:

[DllImport("foo.dll", EntryPoint="_Foo"]
public static extern void Foo(int x)

Replacing int in the C# code with IntPtr or Int64 didn't solve the problem. Any suggestions?


It's System.Int32. Also known as "int".


A long int in C++ == int in C#. Both are 4 bytes long. A long long in C++ == long in C#. (8 bytes).

As Larry above says, if it is picking up a type mismatch, it is not because of the int.

0

精彩评论

暂无评论...
验证码 换一张
取 消