【发布时间】:2012-02-17 17:29:24
【问题描述】:
我有这个 C ActiveX API(没有源代码,只有二进制文件):
// \param a [out] Variant holding a byte array
// \param b [out] Reference to a longlong (Signed 64-bit)
// \param c [out] Reference to a short
short foo(variant* a, longlong* b, short* c);
在 C# 中运行良好:
//auto-generated import:
short foo(ref object a, ref long b, ref short c);
test {
object a=null;
long b=0;
short c=0;
foo(a,b,c); => OK
}
Delphi 2010 中的 NOK(注意 {??Int64}OleVariant 是由 Delphi 导入工具添加的):
//auto-generated import:
function foo(var a: OleVariant;
var b: {??Int64}OleVariant;
var c: Smallint): Smallint;
procedure Test;
var
a, b: OleVariant;
c: Smallint;
begin
foo(a,b,c); => **EOleSysError 'Type mismatch' exception**
end;
【问题讨论】:
-
根据this(netcoole.com/delphi2cs/datatype.htm) long = int64 in Delphi
-
另外,longlong 是一个有符号的 64 位整数
-
@Dorin C/C++ long 在 Windows 上是 32 位。
-
@David 谢谢,32 位和 64 位编译器都是这样吗?
-
@dorin 是的。这是 windows 和 *nix 之间 C 和 C++ 的关键区别。但我现在看到您的评论与 C# 有关,其中 long 是 64 位。