[fpc-pascal] Platform Dependent Integer Types
African Wild Dog
paintedlycaon at gmail.com
Fri Apr 7 17:04:33 CEST 2017
2017-04-06 18:50 GMT-03:00 Mattias Gaertner <nc-gaertnma at netcologne.de>:
> Why do you think that Delphi's longint has 64bits anywhere?
> Delphi's NativeInt is 32 or 64bit depending on platform.
>
>
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Internal_Data_Formats_(Delphi)#Platform-Independent_Signed_Integer_Types
.
As Marco have pointed out, in Windows the Delphi's LongInt type is always
32-bits. On other platforms is platform dependent.
>
> > The documentation says "every platform has a ”native” integer size,
> > depending on whether the platform is 8-bit, 16-bit, 32-bit or 64-bit.
> e.g.
> > On AVR this is 8-bit. ", but it is not clear about which integer types
> are
> > "natives".
>
> Most of FPC's integer types defined via IFDFEs. See
> fpc/rtl/inc/systemh.inc
> You can use Lazarus' Find Declaration on any type and see the
> definition.
> For example:
>
> {$ifdef CPU64}
> SizeInt = Int64;
> SizeUInt = QWord;
> PtrInt = Int64;
> PtrUInt = QWord;
> ValSInt = int64;
> ValUInt = qword;
> CodePointer = Pointer;
> CodePtrInt = PtrInt;
> CodePtrUInt = PtrUInt;
> {$endif CPU64}
>
> {$ifdef CPU32}
> SizeInt = Longint;
> SizeUInt = DWord;
> PtrInt = Longint;
> PtrUInt = DWord;
> ValSInt = Longint;
> ValUInt = Cardinal;
> CodePointer = Pointer;
> CodePtrInt = PtrInt;
> CodePtrUInt = PtrUInt;
> {$endif CPU32}
>
>
> { NativeInt and NativeUInt are Delphi compatibility types. Even though
> Delphi
> has IntPtr and UIntPtr, the Delphi documentation for NativeInt states
> that
> 'The size of NativeInt is equivalent to the size of the pointer on the
> current platform'. Because of the misleading names, these types
> shouldn't be
> used in the FPC RTL. Note that on i8086 their size changes between
> 16-bit
> and 32-bit according to the memory model, so they're not really a
> 'native
> int' type there at all. }
>
Still not clear for me. Are NativeInt and NativeUInt provided for Delphi
compatibility, right? So, if i need an integer type which depends on
platform/fpc compilation mode, which one should i use?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170407/25cd4e00/attachment.html>
More information about the fpc-pascal
mailing list