Difference between revisions of "PtrInt"

From Free Pascal wiki
Jump to navigationJump to search
(categorize page, insert links in dead-end page, rework)
m (→‎application: fix spelling mistake, supposedly insert new external links [spam detection false positive])
Line 2: Line 2:
  
 
== application ==
 
== application ==
* Use <syntaxhighlight lang="delphi" inline>ptrInt</syntaxhighlight> if an <syntaxhighlight lang="pascal" inline>integer</syntaxhighlight> value will eventually be [[Typecast|typecasted]] to a <syntaxhighlight lang="delphi" inline>pointer</syntaxhighlight>.
+
* Use <syntaxhighlight lang="delphi" inline>ptrUInt</syntaxhighlight> if an <syntaxhighlight lang="pascal" inline>integer</syntaxhighlight> value will eventually be [[Typecast|typecasted]] to a <syntaxhighlight lang="delphi" inline>pointer</syntaxhighlight>.
 
* Regardless of the size taken up by its elements, an [[Array|<syntaxhighlight lang="pascal" inline>array</syntaxhighlight>]] cannot have more than <syntaxhighlight lang="delphi" inline>high(ptrInt)</syntaxhighlight> elements. Additionally, the range type must be a subrange of <syntaxhighlight lang="delphi" inline>ptrInt</syntaxhighlight>.<sup>[https://www.freepascal.org/docs-html/current/user/userse62.html]</sup>
 
* Regardless of the size taken up by its elements, an [[Array|<syntaxhighlight lang="pascal" inline>array</syntaxhighlight>]] cannot have more than <syntaxhighlight lang="delphi" inline>high(ptrInt)</syntaxhighlight> elements. Additionally, the range type must be a subrange of <syntaxhighlight lang="delphi" inline>ptrInt</syntaxhighlight>.<sup>[https://www.freepascal.org/docs-html/current/user/userse62.html]</sup>
  

Revision as of 01:07, 23 January 2022

The data types ptrInt (“Peter Int”) and ptrUInt are signed and unsigned integer data types respectively having the same sizeOf of a pointer.

application

  • Use ptrUInt if an integer value will eventually be typecasted to a pointer.
  • Regardless of the size taken up by its elements, an array cannot have more than high(ptrInt) elements. Additionally, the range type must be a subrange of ptrInt.[1]

notes

  • PtrInt/ptrUInt are not necessarily the same size of ALUSInt/ALUUInt.
  • The introduction of ptrInt was a mistake. New code should not use it.
  • IntPtr and nativeInt are aliases for ptrInt.
  • UIntPtr and nativeUInt are aliases for ptrUInt.
  • PtrInt and ptrUInt are redefined by the unit unicodeData.