Delphi Considerations for Multi-Device Applications
Go Up to Considerations for Multi-Device Applications
Contents
- 1 The Extended Data Type is different on different platforms
- 2 The LongInt and LongWord Data Type are different on 64-bit POSIX platforms
- 3 macOS 64-bit (ARM) Target Platform Support
- 4 Stack Alignment Issue on macOS
- 5 Migrating Delphi Applications from Win32 to macOS
- 6 Migrating Delphi Applications from Win32 to Win64
- 7 Migrating Delphi Applications from Win32 to Linux64
- 8 Migrating Delphi Applications from Desktop to Mobile
- 9 In the Clang-based C++ Compilers, 'absolute' Keyword is Not Supported in Interop between Delphi and C++Builder
- 10 Inline Assembly Limitations
- 11 See Also
The Extended Data Type is different on different platforms
The size of the Extended data type is different on each platform. The extended type is highest-precision floating-point type, and it is dependent on the runtime hardware.
- On 32-bit Intel Windows, the Extended type is (still) 10 bytes.
- On 64-bit Intel Windows, the Extended type is an alias for a Double, or 8 bytes.
- On 64-bit Intel Linux and 64-bit Intel macOS, the Extended type is 16 bytes.
- On ARM platforms including 64-bit iOS, 64-bit ARM macOS, 64-bit ARM iOS Simulator, and Android (32-bit and 64-bit), the Extended type is an alias for a Double, or 8 bytes.
Thus you have less precision using an Extended data type on Win64 or ARM platforms compared to Win32. If your applications use the Extended data type and you rely on precision, such as for floating-point operations, this size difference might affect your data.
Very small or very large values are most affected. The precision of the two data types is as follows:
- 1x10308 IEEE Double, supported by 8-bytes Extended type include 64-bit Intel Windows and all ARM platforms
- 1x104932 IEEE Extended, supported by 10 or 16 bytes Extended type include Intel POSIX platforms
If your codebase contains the Extended data type, you will receive the hint message: W1066 Lost Extended floating point precision. Reduced to Double (Delphi). 10-bytes Extended precision floating-point operations are supported in the 32-bit Intel Windows applications and not supported in 64-bit Intel Windows applications. On 64-bit Intel Windows, the precision of floating-point operations with Extended variables is reduced to double precision.
The TExtended80Rec record can be used to work with extended precision floating-point variables on all platforms, but only to read or write to and from the memory and to perform low-level changes (modifying the mantissa, exponent, or sign).
For more information about 64-bit data types, see 64-bit Windows Data Types Compared to 32-bit Windows Data Types.
The LongInt and LongWord Data Type are different on 64-bit POSIX platforms
To keep interoperability between Delphi and POSIX API, for 64-bit POSIX platforms, the size of LongInt and LongWord types are changed to 64-bit. All 32-bit platforms and 64-bit Windows platforms keep 32-bit for the LongInt and LongWord types.
macOS 64-bit (ARM) Target Platform Support
The macOS 64-bit (ARM) natively targets the M1 Apple Silicon CPUs with macOS 11. Use this platform to build native M1 applications (M1 hardware is required to run).
Create all types of supported applications such as console applications, basic FireMonkey applications, FMX applications using database features, and leverage the universal version of embedded InterBase, IBLite.
Universal Binaries
Create a universal binary containing both Intel and ARM code. Ensure the target platform is macOS 64-bit (ARM). In the Project Options, navigate to Building > Delphi Compiler > Compiling > Other, and check "Generate macOS universal binary file (x86_64 + arm64)". Make sure you deploy the application. The deployment manager combines two binaries into one single "Universal" binary; before transferring the application to the target macOS. You can find the universal binary file under the OSXARM64\Debug folder.
Stack Alignment Issue on macOS
For macOS applications, one big issue is the requirement that all memory data be stack-aligned on 16-byte boundaries:
- For details, see Eli Boling's blog
- For Delphi applications, you can use the Code align (Delphi) directive to set 16-byte boundaries.
- Also see the ALIGN_STACK Define in Conditional compilation (Delphi).
Migrating Delphi Applications from Win32 to macOS
The following table summarizes the platform support by the various libraries in RAD Studio:
Library\Platform | Win32 | Win64 | macOS 64-bit |
---|---|---|---|
FMX |
|
|
|
RTL |
|
|
|
VCL |
|
|
Not supported |
Some exceptions do exist in RTL and VCL support for specific platforms.
The VCL is Windows-only and does not support macOS. Applications that target macOS should be built with FireMonkey (FMX).
The majority of the Delphi Run-Time Library (RTL), on the other hand, supports all the Supported Target Platforms. The RTL contains the System, SysUtils, and IOUtils units, and others, which contain platform-neutral elements.
- Delphi applications that use only the RTL (not the VCL) work on Win64 with few changes.
- Any Delphi application that uses the VCL and/or the RTL supports both Win32 and Win64.
For more information about the RTL, see Using the RTL (Run-Time Library).
For more information about FireMonkey, see FireMonkey.
For More Information about the VCL, see Introducing the Visual Component Library (VCL).
Migrating Delphi Applications from Win32 to Win64
The VCL, FMX, and RTL are supported on both Win32 and Win64.
For Delphi Win64 application development, see 64-bit Windows Application Development.
Migrating Delphi Applications from Win32 to Linux64
The VCL and the FMX are not supported on Linux platforms. At this point, Linux supports console applications only. However, the FmxLinux product, available via GetIt Package Manager, allows Linux to be used as a target for FMX applications. For more information, see the FireMonkey for Linux page.
For Delphi Linux Application Development, see Linux Application Development.
Migrating Delphi Applications from Desktop to Mobile
In the Clang-based C++ Compilers, 'absolute' Keyword is Not Supported in Interop between Delphi and C++Builder
If you want to write Delphi code that runs interop with the Clang-enhanced C++ Compilers, you cannot use the "absolute" Delphi directive/keyword in the interface section of a Delphi app when running interop with any of the Clang-enhanced C++ Compilers. However, you can use the "absolute" keyword in the implementation section.
LLVM does not offer the mechanism for a variable to overlay on another, so C++Builder assumes a unique symbol for each variable.
Inline Assembly Limitations
If your code base contains inline assembly code, you might need to make code changes in order to move to new platforms. For more information, see the following topics:
For 64-bit Intel Windows platforms
For ARM platforms and Intel POSIX platforms
These platforms do not support inline-assembler.