C#等效于C ++“signed long int”

时间:2011-03-24 14:53:21

标签: c# marshalling managed

我将C ++ dll导入C#项目,并且在x64机器上,在调试模式下,PInvoke抱怨托管签名与非托管目标签名不匹配。

C ++:

void _Foo(signed long int x);

C#:

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

使用intIntPtr替换C#代码中的Int64并未解决问题。 有什么建议吗?

2 个答案:

答案 0 :(得分:3)

这是System.Int32。也称为“int”。

答案 1 :(得分:0)

C ++中的long int = C {中的int。两者都是4个字节长。 C#中的long long = C {中的long。 (8个字节)。

正如拉里上面所说,如果它出现类型不匹配,那不是因为int。