问题
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
The compiler throw an : [dcc32 Error] E2017 Pointer type required
, error when arrive at the move statement ...
Why ? In Delphi 7 it compile without any problem, why Delphi XE4 doesn't compile ?
The declaration section is as follows :
FBuffers: TBufList;
HoldRec : PChar;
FActiveRecord :integer;
function TDataSet.ActiveBuffer: TRecBuf;
begin
Result := FBuffers[FActiveRecord];
end;
回答1:
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);
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.
来源:https://stackoverflow.com/questions/17770751/e2017-pointer-type-required-using-move-function-in-delphi-7-way