LongWord: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: LongWord
| Old | New | Line | |
|---|---|---|---|
| 1 | + | A **[`longWord`](https://www.freepascal.org/docs-html/rtl/system/longword.html)** is an unsigned integer data type which is *larger* than a [[Word|word]].<sup>[1](https://www.gnu-pascal.de/gpc/LongWord.html)</sup> Larger refers to both the permissible range of values and the [[SizeOf|size]] occupied in a [[Packed|packed]] structure. | |
| 2 | + | ||
| 3 | + | ## Definition | |
| 4 | + | ||
| 5 | + | ### GNU Pascal Compiler | |
| 6 | + | ||
| 7 | + | In [[GNU Pascal]] a `longWord` is compatible to GNU [[Pascal for C users|C]]’s [`long long unsigned int`](https://www.freepascal.org/docs-html/rtl/ctypes/culonglong.html). On *some* platforms it is 64 bits wide and thus has a range of `0..18446744073709551615` ($`\mathbb{Z} \cap \left[0, 2^{64}\right)`$). | |
| 8 | + | ||
| 9 | + | ### Free Pascal Compiler | |
| 10 | + | ||
| 11 | + | For compatibility with [[Delphi]], the [[FPC]] *always* defines `longWord` as a 32-bit quantity, thus it may assume a value in the range `0..4294967295` ($`\mathbb{Z} \cap \left[0, 2^{32}\right)`$). The defunct [[Mode GPC|{$mode GPC}]] [[Compiler Mode|compiler compatibility mode]] did not change this. In this definition, [`dWord`](https://www.freepascal.org/docs-html/rtl/system/dword.html) (double word) is an alias for `longWord`. As of version 3.2.0 the data type [[Cardinal|cardinal]] is an *unconditional* alias for `longWord`. | |
| 12 | + | ||
| 13 | + | ## Application | |
| 14 | + | ||
| 15 | + | - Because the FPC’s definition is fixed in size, it is frequently used when defining the *exact* memory layout of [[Record|record]] data types that will be passed to foreign language libraries. If the external library is written C, use of the [`cTypes unit`](https://www.freepascal.org/docs-html/rtl/ctypes/index.html) is recommended. | |
| 16 | + | - Likewise, the GPC guarantees compatibility of certain integer data types with GNU C.<sup>[2](https://www.gnu-pascal.de/gpc/Summary-of-Integer-Types.html)</sup> For maximum range, the GPC also defines `longestWord`. | |
| 17 | + | ||
| 18 | + | ## See Also | |
| 19 | + | ||
| 20 | + | - [[Longint|longInt]] | |
| 21 | + | - [`pLongWord`](https://www.freepascal.org/docs-html/rtl/system/plongword.html) | |
| 22 | + | - [`types.tLongWordDynArray`](https://www.freepascal.org/docs-html/rtl/types/tlongworddynarray.html) | |
| 23 | + | ||
| 24 | + | --- | |
| 25 | + | *From the Free Pascal wiki, page "LongWord", as it stood on 2023-12-22 after a change by Alextpp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
