Hi Tomas, 

Thanks for clarifying. I will use PtrUInt to store the
pointer address in. BTW: the documentation it says not to use PtrInt
because it's signed and therefore smaller than a pointer (as in max
value). 

Also there seems to be an error in the documentation. On
http://www.freepascal.org/docs-html/rtl/system/ptruint.html [4] it is
described that PtrUInt is an alias to DWord. However, it depends on the
architecture which type it actually is. Could someone please correct the
docs? 

TIA 

Regards, Darius 

On 1 okt '12, Tomas Hajny wrote: 

> On
Mon, October 1, 2012 10:43, dhkblas...@zeelandnet.nl [1]wrote:
> 
>
Hi,
> 
>> I want to ask if casting an integer to a pointer is valid over
all platforms. See below: p: PInteger; v: longint; [...] v := 4235423; p
:= PInteger(v); Of course, the value of the pointer adress may vary, but
in general is this a valid way to assign a pointer? Or will some
platforms or architecture give problems?
> 
> Use PtrInt (signed) or
PtrUInt (unsigned) types instead of longint, etc.
> The former two are
guaranteed to work for all architectures and platforms.
> Your
particular example fails on all 64-bit architectures (among others)
>
immediately.
> 
> Tomas
> 
>
_______________________________________________
> fpc-pascal maillist -
fpc-pascal@lists.freepascal.org [2]
>
http://lists.freepascal.org/mailman/listinfo/fpc-pascal [3]

 


Links:
------
[1] mailto:dhkblas...@zeelandnet.nl
[2]
mailto:fpc-pascal@lists.freepascal.org
[3]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[4]
http://www.freepascal.org/docs-html/rtl/system/ptruint.html
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to