Difference between revisions of "PtrInt"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "'''PtrInt''' is signed integer type which has the same SizeOf as Pointer. '''PtrUInt''' is unsigned integer type which has the same SizeOf as Pointer.")
 
(add pronunciation of ptrUInt)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''PtrInt''' is signed integer type which has the same SizeOf as Pointer.
+
The data types '''{{Doc|package=RTL|unit=system|identifier=ptrint|text=<syntaxhighlight lang="delphi" inline>ptrInt</syntaxhighlight>}}''' (“Peter Int”) and '''{{Doc|package=RTL|unit=system|identifier=ptruint|text=<syntaxhighlight lang="delphi" inline>ptrUInt</syntaxhighlight>}}''' (“Pee true Int”) are signed and unsigned [[Integer|<syntaxhighlight lang="pascal" inline>integer</syntaxhighlight>]] [[Data type|data types]] respectively having the same [[SizeOf|<syntaxhighlight lang="delphi" inline>sizeOf</syntaxhighlight>]] of a [[Pointer|<syntaxhighlight lang="delphi" inline>pointer</syntaxhighlight>]].
  
'''PtrUInt''' is unsigned integer type which has the same SizeOf as Pointer.
+
== application ==
 +
* 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>
 +
 
 +
== notes ==
 +
* <syntaxhighlight lang="delphi" inline>PtrInt</syntaxhighlight>/<syntaxhighlight lang="delphi" inline>ptrUInt</syntaxhighlight> are not necessarily the same size of <syntaxhighlight lang="delphi" inline>ALUSInt</syntaxhighlight>/<syntaxhighlight lang="delphi" inline>ALUUInt</syntaxhighlight>.
 +
* The introduction of <syntaxhighlight lang="delphi" inline>ptrInt</syntaxhighlight> was a mistake. New code should not use it.
 +
* {{Doc|package=RTL|unit=system|identifier=intptr|text=<syntaxhighlight lang="delphi" inline>IntPtr</syntaxhighlight>}} and {{Doc|package=RTL|unit=system|identifier=nativeint|text=<syntaxhighlight lang="delphi" inline>nativeInt</syntaxhighlight>}} are aliases for <syntaxhighlight lang="delphi" inline>ptrInt</syntaxhighlight>.
 +
* {{Doc|package=RTL|unit=system|identifier=uintptr|text=<syntaxhighlight lang="delphi" inline>UIntPtr</syntaxhighlight>}} and {{Doc|package=RTL|unit=system|identifier=nativeint|text=<syntaxhighlight lang="delphi" inline>nativeUInt</syntaxhighlight>}} are aliases for <syntaxhighlight lang="delphi" inline>ptrUInt</syntaxhighlight>.
 +
* <syntaxhighlight lang="delphi" inline>PtrInt</syntaxhighlight> and <syntaxhighlight lang="delphi" inline>ptrUInt</syntaxhighlight> are redefined by the <syntaxhighlight lang="delphi" inline>unit</syntaxhighlight> <syntaxhighlight lang="delphi" inline>unicodeData</syntaxhighlight>.
 +
 
 +
[[Category: Data types]]
 +
[[Category: FPC]]

Latest revision as of 18:26, 25 January 2022

The data types ptrInt (“Peter Int”) and ptrUInt (“Pee true Int”) 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.