E2017指针类型需要在Delphi 7中使用移动功能 [英] E2017 Pointer type required using move function in Delphi 7 way

查看:65
本文介绍了E2017指针类型需要在Delphi 7中使用移动功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将项目从Delphi 7移植到新的Delphi XE4,并且我遇到 move 函数的问题:

I'm trying to port a project from Delphi 7 to the new Delphi XE4 and I'm facing a problem with the move function :

{Create a temp record buffer}
HoldRec := AllocMem(RecordSize);
{Fill the temp record buffer with the current record}
move(ActiveBuffer^, HoldRec^, RecordSize); //Here the E2017 Error

编译器抛出: [dcc32错误] E2017必需的指针类型,到达 move 语句时出错...

The compiler throw an : [dcc32 Error] E2017 Pointer type required , error when arrive at the move statement ...

为什么?在Delphi 7中,它可以毫无问题地进行编译,为什么Delphi XE4不进行编译?

Why ? In Delphi 7 it compile without any problem, why Delphi XE4 doesn't compile ?

声明部分如下:

FBuffers: TBufList;
HoldRec : PChar;
FActiveRecord :integer;


function TDataSet.ActiveBuffer: TRecBuf;
begin
  Result := FBuffers[FActiveRecord];
end;

推荐答案

在Delphi 7中,TRecBuf是某种类型的指针,我不确定到底是什么.在XE4中,它被声明为NativeInt.您需要将其强制转换为指针,以使您的代码得以编译.

In Delphi 7, TRecBuf was a pointer of some type, I'm not sure exactly what. In XE4, it is declared as NativeInt. You'd need to cast it to be a pointer to make your code compile.

move(Pointer(ActiveBuffer)^, HoldRec^, RecordSize); 

我还要指出,HoldRec在Unicode XE4中现在是PWideChar,但在Delphi 7中是PAnsiChar.我怀疑您需要以一种或另一种方式处理.很有可能您需要将声明更改为PAnsiChar,但我不能从这里肯定地说.

I would also point out that HoldRec is now PWideChar in Unicode XE4, but it was PAnsiChar in Delphi 7. I suspect you'll need to deal with that one way or another. Quite possibly you'd need to change the declaration to PAnsiChar, but I cannot say for sure from here.

这篇关于E2017指针类型需要在Delphi 7中使用移动功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆