PtrInt type
Signed integer type with same size as Pointer.
Declaration
PtrInt = Int64Description
Ptrint is a signed integer type which has always the same size as a
pointer. Ptrint is considered harmful and should almost never be used in actual
code, because pointers are normally unsigned. For example, consider the following
code:
getmem(p,2048); {Assume the address of p becomes $7ffffff0.}
q:=pointer(ptrint(p)+1024)); {Overflow error.}
writeln(q>p); {Incorrect answer.}
Ptrint might have a valid use when two pointers are subtracted from each other if it is unknown which pointer has the largest address. However, even in this case ptrint causes trouble in case the distance is larger than high(ptrint) and must be used with great care.
The introduction of the ptrint type was a mistake. Please use
PtrUInt instead.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
