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)), 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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to