PtrInt

Signed integer type with same size as Pointer.

Declaration

Source position: systemh.inc line 419

Type
PtrInt = LongInt

Description

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

Name Description
ptruInt Unsigned integer type with same size as Pointer.