[fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

Graeme Geldenhuys graeme at mastermaths.co.za
Tue Nov 17 10:38:37 CET 2009


Jonas Maebe wrote:
>> How to I solve this compiler hint?
> 
> Don't cast ordinals to pointers.


:-)


> Replace the PtrUInt types casts with PByte (or Pointer) type casts.

So in that case because a untyped parameters are treated like generic
Pointer types whereby arithmetic increments in byte size, I don't
actually need any type casts the parameters at all?  Is the code below
safe?  It seem to work fine in our projects and data.


procedure XorBlock(var InData1, InData2; Size: longword);
var
  i: longword;
begin
  for i:= 1 to Size do
    Pbyte(@InData1+i-1)^ :=
       Pbyte(@InData1+i-1)^ xor
       Pbyte(@InData2+i-1)^;
end;



Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/




More information about the fpc-pascal mailing list