Re: [fpc-pascal] Platform Dependent Integer Types
2017-04-07 12:33 GMT-03:00 Michael Van Canneyt : > > > On Fri, 7 Apr 2017, African Wild Dog wrote: > > 2017-04-07 12:10 GMT-03:00 Michael Van Canneyt : >> >> >>> NativeInt and NativeUInt are indeed provided for Delphi compatibility. >>> >>> Which integer type to chose : That depends. What do you want to achieve >>> exactly ? >>> >>> >>> In Delphi, if i want an integer type which depends on the target platform >> (32 or 64 bits) i can use the NativeInt and NativeUInt types. What is the >> FPC standard type for this? PrtInt and PtrUInt? (I usually mix both delphi >> mode and objfpc mode units in the same project). >> > > You can use PrtInt and PtrUInt for this or NativeInt and NativeUINT, they > should be equivalent. > > The only 'dubious' case may be the 8086 msdos case, which is somewhat > confused > about what exactly constitutes a pointer... There you may be better off > with NativeInt and NativeUINT. > > Thank you for the clarification. Best regards ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
On Fri, 7 Apr 2017, African Wild Dog wrote: 2017-04-07 12:10 GMT-03:00 Michael Van Canneyt : NativeInt and NativeUInt are indeed provided for Delphi compatibility. Which integer type to chose : That depends. What do you want to achieve exactly ? In Delphi, if i want an integer type which depends on the target platform (32 or 64 bits) i can use the NativeInt and NativeUInt types. What is the FPC standard type for this? PrtInt and PtrUInt? (I usually mix both delphi mode and objfpc mode units in the same project). You can use PrtInt and PtrUInt for this or NativeInt and NativeUINT, they should be equivalent. The only 'dubious' case may be the 8086 msdos case, which is somewhat confused about what exactly constitutes a pointer... There you may be better off with NativeInt and NativeUINT. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
2017-04-07 12:10 GMT-03:00 Michael Van Canneyt : > > NativeInt and NativeUInt are indeed provided for Delphi compatibility. > > Which integer type to chose : That depends. What do you want to achieve > exactly ? > > In Delphi, if i want an integer type which depends on the target platform (32 or 64 bits) i can use the NativeInt and NativeUInt types. What is the FPC standard type for this? PrtInt and PtrUInt? (I usually mix both delphi mode and objfpc mode units in the same project). ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
In our previous episode, African Wild Dog said: > > > 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. Note that this is a very recent development. It started with the iOS 64-bit arm compiler a while back, and now since weeks their new Linux offering. Both however are a different compiler than the regular. > 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? For what purpose? There are only ones that scale with pointer size, and then any of the native(u)int, ptr(u)int or int(u)ptr types are ok. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
On Fri, 7 Apr 2017, African Wild Dog wrote: 2017-04-06 18:50 GMT-03:00 Mattias Gaertner : 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. In short: It is platform dependent in Delphi. 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? NativeInt and NativeUInt are indeed provided for Delphi compatibility. Which integer type to chose : That depends. What do you want to achieve exactly ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
On Fri, 7 Apr 2017, African Wild Dog wrote: 2017-04-07 11:15 GMT-03:00 Marco van de Voort : In our previous episode, African Wild Dog said: Which integer types have their size dependent on platform? E.g. in Delphi, LongInt can 32 or 64 bits depending on the platform. In Delphi they retroactively equated longint to C long, being 32-bit on 64-bits windows and 64-bit on Linux. The Delphi Linux compiler is btw a different compiler than windows. On FPC it is always 32-bit. Ptrint and ptruint scale with pointer size, and integer depends on compilation mode, 16 or 32-bit. So, is the size of "Integer" type dependent on the compilation mode? (Delphi is always 32 bits) Yes. It is 16 bit in fpc/tp mode, 32 bit in Delphi/ObjFPC and MacPas. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
In our previous episode, African Wild Dog said: > > On FPC it is always 32-bit. Ptrint and ptruint scale with pointer size, and > > integer depends on compilation mode, 16 or 32-bit. > > > So, is the size of "Integer" type dependent on the compilation mode? Yes. > (Delphi is always 32 bits) In objfpc and delphi modes it is 32-bit, in more TP oriented modes it is 16-bit as it was in TP. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
2017-04-06 18:50 GMT-03:00 Mattias Gaertner : > 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? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
2017-04-07 11:15 GMT-03:00 Marco van de Voort : > In our previous episode, African Wild Dog said: > > Which integer types have their size dependent on platform? > > E.g. in Delphi, LongInt can 32 or 64 bits depending on the platform. > > In Delphi they retroactively equated longint to C long, being 32-bit on > 64-bits windows and 64-bit on Linux. The Delphi Linux compiler is btw a > different compiler than windows. > > On FPC it is always 32-bit. Ptrint and ptruint scale with pointer size, and > integer depends on compilation mode, 16 or 32-bit. > > So, is the size of "Integer" type dependent on the compilation mode? (Delphi is always 32 bits) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Platform Dependent Integer Types
In our previous episode, African Wild Dog said: > Which integer types have their size dependent on platform? > E.g. in Delphi, LongInt can 32 or 64 bits depending on the platform. In Delphi they retroactively equated longint to C long, being 32-bit on 64-bits windows and 64-bit on Linux. The Delphi Linux compiler is btw a different compiler than windows. On FPC it is always 32-bit. Ptrint and ptruint scale with pointer size, and integer depends on compilation mode, 16 or 32-bit. For the C compiler that FPC corresponds with (usually gcc), there are types that correspond with C types in unit ctypes. Maybe some of the new ultra small targets like AVR make exceptions, but those are the general rules. > On AVR this is 8-bit. ", but it is not clear about which integer types are > "natives". The typical pascal solution is to use subranges and hope the compiler will optimize it. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal