[fpc-pascal] Conversion between ordinals and pointers is not portable

Max Vlasov max.vlasov at gmail.com
Wed Mar 2 11:38:00 CET 2011


On Wed, Mar 2, 2011 at 12:33 PM, Jonas Maebe <jonas.maebe at elis.ugent.be>wrote:

>
> On 02 Mar 2011, at 09:02, Roland Turcan wrote:
>
>   ...
>>  p := PByteArray (PtrUInt (@FData.Content[0]) + MOffset);
>>  ...
>>
>>
>> But the compiler informs about %subj%.
>>
>> How to get rid of this warning and to make code portable?
>>
>
> Typecast to PByte instead of to PtrUInt.
>
>

If Roland wants to keep compatibility with Delphi for some reasons, I
suggest using something like

{$ifdef fpc}
  AddrInt = PByte;
{$else}
  AddrInt = integer;
{$endif}

if this approach is used the line
  PByteArray (AddrInt(@FData.Content[0]) + MOffset)
should not lead to any question both from fpc and Delphi

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110302/3ed77035/attachment.html>


More information about the fpc-pascal mailing list