[fpc-devel] Warning: Conversion between ordinals and pointers is not portable
Jonas Maebe
jonas.maebe at elis.ugent.be
Sun Dec 2 22:05:29 CET 2012
On 02 Dec 2012, at 20:58, Martin wrote:
> Ok now I am curious
>
> SomePointer := Pointer(PtrInt(SomeNumber))
> SomePointer := Pointer(PtrUInt(SomeNumber))
>
> The 2nd gives the warning.
> Warning: Conversion between ordinals and pointers is not portable
>
>
> But the first does not.
>
> Yet PtrInt/PtrUInt are both the size of pointer?
As always when asking about help with something the compiler does, post a complete and compilable program that demonstrates your question. The following code does not produce any warning (it will produce hints):
const
somenumber: shortint=2;
var
somepointer: pointer;
begin
SomePointer := Pointer(PtrInt(SomeNumber));
SomePointer := Pointer(PtrUInt(SomeNumber))
end.
It also doesn't produce a warning either if the type of somenumber is changed to byte, longint or int64, nor when changing somenumber into a symbolic constant; all regardless of whether I compile for 32 or 64 bit.
Jonas
More information about the fpc-devel
mailing list