[Lazarus] pointer to int/other 32/64 bit?

ik idokan at gmail.com
Sun Jan 4 09:07:45 CET 2009


On Sun, Jan 4, 2009 at 5:15 AM, Martin Friebe <lazarus at mfriebe.de> wrote:
> Hi
> I know there are issues becuse on 64 bity systems pointer are 8 byte.
> And I know there is PTRInt / PTRUInt. An integer of the correct size.
>
> But how much casting is needed?
>
> if I have an integer, word, or byte do I need to go via PTRInt? That is
> if I know the data is only 4 or less bytes.
>
> So what happens if I do
>  SomeInt = Pointer(foo);
> Will that compile on 64 bit, or do I need
>  SomeInt = PTRInt(Pointer(foo));

Don't do that, do instead:
 SomeInt = PTRInt(foo);

If you cast it (twice) to pointer it will not result in what you
expected, and on 64 bit, you will not solve the problem.

>
> In both case the data must be truncated, so the question is not will it
> work (the data is small enough).
> the question is will it compile.
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>

Ido



More information about the Lazarus mailing list