Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-01

pointer to int/other 32/64 bit?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Friebe

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));

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.

Reply by email

ik
to Martin Friebe
Martin Friebe wrote 13 lines
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.

Show quoted text 9 lines
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 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Ido

Reply by email