[fpc-pascal] Assigning pointer address
dhkblaszyk at zeelandnet.nl
dhkblaszyk at zeelandnet.nl
Mon Oct 1 13:21:19 CEST 2012
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, dhkblaszyk at 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 at lists.freepascal.org [2]
>
http://lists.freepascal.org/mailman/listinfo/fpc-pascal [3]
Links:
------
[1] mailto:dhkblaszyk at zeelandnet.nl
[2]
mailto:fpc-pascal at lists.freepascal.org
[3]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[4]
http://www.freepascal.org/docs-html/rtl/system/ptruint.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121001/aa953b67/attachment.html>
More information about the fpc-pascal
mailing list