Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-07

LongInt and LongWord types

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcelo Rocha

Delphi's LongInt and LongWord are 32 bits on Windows, but 64 bits on supported Posix platforms(
http://docwiki.embarcadero.com/RADStudio/Rio/en/Simple_Types_(Delphi)), following the conventions from LP64/LLP64. FreePascal declares with the same size for all platforms.

What's the best way to do portable code: using types clong and culong?

FreePascal could emit a warning when compiling a code with Longint/Longword variables, targeting a Posix platform, with {$mode delphi}?

Regards,

Marcelo Rocha

Reply by email

Sven Barth
to Marcelo Rocha
Marcelo Rocha wrote 7 lines
Delphi's LongInt and LongWord are 32 bits on Windows, but 64 bits on supported Posix platforms(http://docwiki.embarcadero.com/RADStudio/Rio/en/Simple_Types_(Delphi)), following the conventions from LP64/LLP64. FreePascal declares with the same size for all platforms. What's the best way to do portable code: using types clong and culong?

Best declare your own aliases with the help of some ifdefs (clong/culong don't exist in Delphi, so you'd have to declare aliases anyway).

FreePascal could emit a warning when compiling a code with Longint/Longword variables, targeting a Posix platform, with {$mode delphi}?

LongInt and LongWord are the *base* types used by FPC. So *everything* is using them, because Integer and Cardinal are merely aliases. Not to mention that FPC has provided 64-bit support first on Posix platforms way back and for that is was decided to keep the size of LongInt and LongWord the same on all platforms for consistency. This will not be changed and there won't be a warning for that.
What there is, is a remark in the documention (in
https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1 ): "Remark In newer Delphi versions, the longint type is platform and CPU dependent. This is not so in FPC, where longint is 32-bit on all platforms."

Regards,
Sven

Reply by email

Vojtěch Čihák
to Sven Barth

I suspect Embarcadero that they often intently design Delphi to be not compatible with FPC. V.
______________________________________________________________

Show quoted text 5 lines
Od: "Sven Barth via fpc-pascal" Komu: Datum: 09.07.2020 07:30 Předmět: Re: [fpc-pascal] LongInt and LongWord types

Am 08.07.2020 um 23:00 schrieb Marcelo Rocha via fpc-pascal:Delphi's LongInt and LongWord are 32 bits on Windows, but 64 bits on supported Posix platforms(http://docwiki.embarcadero.com/RADStudio/Rio/en/Simple_Types_(Delphi) <http://docwiki.embarcadero.com/RADStudio/Rio/en/Simple_Types_(Delphi)>), following the conventions from LP64/LLP64. FreePascal declares with the same size for all platforms. What's the best way to do portable code: using types clong and culong? Best declare your own aliases with the help of some ifdefs (clong/culong don't exist in Delphi, so you'd have to declare aliases anyway).

FreePascal could emit a warning when compiling a code with Longint/Longword variables, targeting a Posix platform, with {$mode delphi}? LongInt and LongWord are the *base* types used by FPC. So *everything* is using them, because Integer and Cardinal are merely aliases. Not to mention that FPC has provided 64-bit support first on Posix platforms way back and for that is was decided to keep the size of LongInt and LongWord the same on all platforms for consistency. This will not be changed and there won't be a warning for that. What there is, is a remark in the documention (in https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1 <https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-250003.1.1> ): "Remark In newer Delphi versions, the longint type is platform and CPU dependent. This is not so in FPC, where longint is 32-bit on all platforms."

Regards,
Sven

----------

Reply by email