[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'System' (#rtl)

PtrInt

Signed integer type with same size as Pointer.

Declaration

Source position: systemh.inc line 259

type PtrInt = LongInt;

Description

Ptrint is a signed integer type which has always the same size as a pointer. Ptrint is considered harmfull 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 substracted 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

ptruInt

  

Unsigned integer type with same size as Pointer.

The latest version of this document can be found at lazarus-ccr.sourceforge.net.