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

Paul Nicholls paulfnicholls at gmail.com
Fri Nov 20 05:36:53 CET 2009


----- Original Message ----- 
From: "Tomas Hajny" <XHajT03 at mbox.vol.cz>
To: <graemeg at opensoft.homeip.net>; "FPC-Pascal users discussions" 
<fpc-pascal at lists.freepascal.org>
Sent: Wednesday, November 18, 2009 10:40 PM
Subject: Re: [fpc-pascal] How to solve "Conversion between ordinals and 
pointers is not portable"


> On Tue, November 17, 2009 10:48, Graeme Geldenhuys wrote:
>> dmitry boyarintsev wrote:
>>>
>>> procedure XorBlock(var InData1, InData2; Size: longword);
>>> var
>>>   b1 : PByte;
>>>   b2 ; PByte;
>>
>> Changing those declarations to PByteArray type solves the compiler error
>> in FPC.
>>
>> var
>>   b1: PByteArray;
>>   b2: PByteArray;
>
> I suggest being careful with PByteArray, or at least make sure that you
> know the type definition and you know where this definition comes from.
> First, it is certainly very different from PByte regarding the supported
> range. PByte allows addressing the complete memory space, PByteArray is
> limited (well, at least it is if you turn range checking on ;-) ).
> Moreover, PByte is defined in unit system and is thus common for all FPC
> programs, whereas there are several different definitions for PByteArray
> in the FPC RTL, out of which at least two are in common (cross-platform)
> units (in particular SysUtils and Objects), and there's a lot of other
> (3rd party / user) code containing other definitions of P/TByteArray.
>
> Tomas

Personally, I usual just declare my own definition of PByteArray when I need
it just to be safe....

{Delphi Code}
Type
    PByteArray = ^TByteArray;
    TByteArray = Array[0..MaxInt - 1] Of Byte;
{/Delphi Code}

cheers,
Paul 




More information about the fpc-pascal mailing list