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

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Nov 17 10:27:35 CET 2009


On 17 Nov 2009, at 10:17, Aleksa Todorovic wrote:

> On Tue, Nov 17, 2009 at 10:05, Jonas Maebe <jonas.maebe at elis.ugent.be> wrote:
>> 
>> Replace the PtrUInt types casts with PByte (or Pointer) type casts.
>> 
> 
> Does that mean that (PByte(p) + N) = (Pointer(p) + N) for
> pointer-castable p and integer N?

Yes. The general rule is that adding an ordinal N to a pointer type P increases P by the size of the type this pointer points to times N. Sizeof(pbyte^) = sizeof(byte) = 1. 

Pointer is a special case since it's untyped (sizeof(pointer^) = 0 in the FPC), and adding an ordinal N to an untyped pointer also increases its value by N.


Jonas


More information about the fpc-pascal mailing list