![PlatformIdentifiers | Embarcadero RAD Studio Delphi C++Builder Blogs Platform Identifiers](https://i0.wp.com/blogs.embarcadero.com/wp-content/uploads/2021/12/PlatformIdentifiers-9523419.png?resize=1140%2C694&ssl=1)
I was looking through the “What’s New in version 11 Alexandria” and found a cool tidbit about small changes in the RTL for “Platform Identifiers“. Using these platform identifiers can help in your cross platform development projects. Ensuring that all of the platform related identifiers use a consistent naming pattern will also help in your programming efforts.
1 2 3 4 5 |
The RTL adds a new platform identifier, pidOSXArm64 for the macOS/Arm64 platform. The existing pidAndroid32Arm and pidAndroid64Arm identifiers are replaced by the new pidAndroidArm32 and pidAndroidArm64. Now, all platform related identifiers use the same format and order of the compilers: <Platform name> <Architecture name> <Bitness> |
You will find the new platform identifiers in the System.Classes.pas and System.Classes.hpp files. Note: a few of the platform identifiers are now marked with the deprecated attribute.
C++Builder note: In the screen grab above, I used the “Classic” C++ compiler to display the deprecated warning message in the Message Window. In the DocWiki there is a note about workarounds in using the Clang-enhanced compilers and deprecated attributes. The DocWiki entry says to “use #pragma obsolete as a workaround for the deprecated attribute.”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
System.Classes.pas { Platform identifiers } pidWin32 = $00000001; pidWin64 = $00000002; pidOSX32 = $00000004; pidiOSSimulator32 = $00000008; pidiOSSimulator = pidiOSSimulator32 deprecated 'Use pidiOSSimulator32'; pidAndroidArm32 = $00000010; pidAndroid32Arm = pidAndroidArm32 deprecated 'Use pidAndroidArm32'; pidAndroid = pidAndroidArm32 deprecated 'Use pidAndroidArm32'; pidLinux32 = $00000020; pidiOSDevice32 = $00000040; pidiOSDevice = pidiOSDevice32 deprecated 'Use pidiOSDevice32'; pidLinux64 = $00000080; pidWinNX32 = $00000100; pidWinIoT32 = $00000200; // Embedded IoT (Internet of Things) Windows w/ Intel Galileo pidiOSDevice64 = $00000400; pidWinARM32 = $00000800; pidWin32ARM = pidWinARM32 deprecated 'Use pidWinARM32'; pidOSX64 = $00001000; pidLinuxArm32 = $00002000; pidLinuxArm64 = $00004000; pidAndroidArm64 = $00008000; pidAndroid64Arm = pidAndroidArm64 deprecated 'Use pidAndroidArm64'; pidiOSSimulator64 = $00010000; pidOSXArm64 = $00020000; pidWinArm64 = $00040000; pidiOSSimulatorArm64 = $00080000; pidAllPlatforms = pidWin32 or pidWin64 or pidOSX32 or pidOSX64 or pidOSXArm64 or pidiOSDevice32 or pidiOSDevice64 or pidiOSSimulator32 or pidiOSSimulator64 or pidAndroidArm32 or pidAndroidArm64 or pidLinux64; { Platform family identifiers } pfidWindows = pidWin32 or pidWin64; pfidOSX = pidOSX32 or pidOSX64 or pidOSXArm64; pfidiOS = pidiOSDevice32 or pidiOSDevice64 or pidiOSSimulator32 or pidiOSSimulator64; pfidAndroid = pidAndroidArm32 or pidAndroidArm64; pfidLinux = pidLinux64; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
System.Classes.hpp static const System::Int8 pidWin32 = System::Int8(0x1); static const System::Int8 pidWin64 = System::Int8(0x2); static const System::Int8 pidOSX32 = System::Int8(0x4); static const System::Int8 pidiOSSimulator32 = System::Int8(0x8); static const System::Int8 pidiOSSimulator _DEPRECATED_ATTRIBUTE1("Use pidiOSSimulator32") = System::Int8(0x8); static const System::Int8 pidAndroidArm32 = System::Int8(0x10); static const System::Int8 pidAndroid32Arm _DEPRECATED_ATTRIBUTE1("Use pidAndroidArm32") = System::Int8(0x10); static const System::Int8 pidAndroid _DEPRECATED_ATTRIBUTE1("Use pidAndroidArm32") = System::Int8(0x10); static const System::Int8 pidLinux32 = System::Int8(0x20); static const System::Int8 pidiOSDevice32 = System::Int8(0x40); static const System::Int8 pidiOSDevice _DEPRECATED_ATTRIBUTE1("Use pidiOSDevice32") = System::Int8(0x40); static const System::Byte pidLinux64 = System::Byte(0x80); static const System::Word pidWinNX32 = System::Word(0x100); static const System::Word pidWinIoT32 = System::Word(0x200); static const System::Word pidiOSDevice64 = System::Word(0x400); static const System::Word pidWinARM32 = System::Word(0x800); static const System::Word pidWin32ARM _DEPRECATED_ATTRIBUTE1("Use pidWinARM32") = System::Word(0x800); static const System::Word pidOSX64 = System::Word(0x1000); static const System::Word pidLinuxArm32 = System::Word(0x2000); static const System::Word pidLinuxArm64 = System::Word(0x4000); static const System::Word pidAndroidArm64 = System::Word(0x8000); static const System::Word pidAndroid64Arm _DEPRECATED_ATTRIBUTE1("Use pidAndroidArm64") = System::Word(0x8000); static const int pidiOSSimulator64 = int(0x10000); static const int pidOSXArm64 = int(0x20000); static const int pidWinArm64 = int(0x40000); static const int pidiOSSimulatorArm64 = int(0x80000); static const int pidAllPlatforms = int(0x394df); static const System::Int8 pfidWindows = System::Int8(0x3); static const int pfidOSX = int(0x21004); static const int pfidiOS = int(0x10448); static const System::Word pfidAndroid = System::Word(0x8010); static const System::Byte pfidLinux = System::Byte(0x80); |
Interested in using Embarcadero’s IDE Software? It will help you Build Apps 5x Faster With One Codebase for Windows, Android, iOS, macOS, and Linux. Request a free trial here.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
This sounds really useful but I’m having some trouble with documentation.
I can find the definitions in System.Classes.pas (Delphi), but in the same unit I see use of
$IFDEF MSWINDOWS
$IFDEF ANDROID
and so on.
Can you point to some additional discussion?
These kind of compiler directives (as they are called) allow you to have blocks of code which will only get compiled into your apps if they evaluate to true.
So, for example:
{$IDEF ANDROID}
// Do something here which you only want to execute when the program is compiled for an Android device...
{$ENDIF}
The full set of directives which you can use can be found here: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Conditional_compilation_(Delphi)