Go Up to Delphi Compiler Directives (List) Index

This section will change the reported hardware model and production year on the main “About This Mac” page. On a Hackintosh this page will usually report the Model you have selected in your SMBIOS settings, but you might want it to say something different. For example, for best performance on my hack, I have an iMac model set in my SMBIOS. Target Display Mode is a feature that allows you to use the display of an iMac to view the screen output from a second, external, Mac. For example, I am able to use Target Display Mode so that my late–2009 27' iMac can display the output from my late–2009 Mac mini. If your target Mac is turned ON, go to System Preferences Startup Disk and select Target Disk Mode. Once you have Target Mode turned ON, you are all set to transfer files.

Tim Cook says Apple is now selling more M1 Macs than Intel-based models, despite them only being released in November — Despite only being released in November, sales of the M1-powered MacBook Air, MacBook Pro, and Mac mini now represent the majority of Mac sales, outperforming Mac computers powered. If you have already wiped the internal disk, put the working Mac into target mode and boot the broken Mac from the OS installed on the working Mac, plugged in via thunderbolt or Firwire (depending on connectivity options).

Conditional compilation is based on the existence and evaluation of constants, the status of compiler switches, and the definition of conditional symbols.

  • 2Using Conditional Defines for the Compiler Version

Conditional symbols work like Boolean variables: they are either defined (True) or undefined (False). Any valid conditional symbol is treated as false until it has been defined.

Targeting Change Mac OS

You can define a conditional in the following ways:

  • Use the {$DEFINE} directive to set a specified symbol to True, and the {$UNDEF} directive to set the symbol to False.
  • Use the -D switch with the command-line compiler (this option is supported by all the Delphi compilers).
  • Add the symbol to the Conditional Defines field on the Project > Options > Delphi Compiler page.

The conditional directives {$IFDEF}, {$IFNDEF}, {$IF}, {$ELSEIF}, {$ELSE}, {$ENDIF}, and {$IFEND} allow you to compile or suppress code based on the status of a conditional symbol. {$IF} and {$ELSEIF} allow you to base conditional compilation on declared Delphi identifiers. {$IFOPT} compiles or suppresses code depending on whether a specified compiler switch is enabled.

For example, the following Delphi code snippet processes differently depending on whether the DEBUG conditional define is set ({$DEFINE DEBUG}):

Note: Conditional symbols are not Delphi identifiers and cannot be referenced in actual program code. Similarly, Delphi identifiers cannot be referenced in any conditional directives other than {$IF} and {$ELSEIF}.
Note: Conditional definitions are evaluated only when source code is recompiled. If you change a conditional symbol status and then rebuild a project, source code in unchanged units may not be recompiled. Use Project > Build All Projects to ensure that everything in your project reflects the current status of conditional symbols.
Note: If you modify the name of a conditional define in the Project > Options > Delphi Compiler, you need to Build your project (Project > Build <ProjectName> or Shift + F9) for the changes to take effect.

Conditional-directive constructions can be nested up to 32 levels deep. For every {$IFxxx}, the corresponding {$ENDIF} or {$IFEND} must be found within the same source file. Conditional symbols must start with a letter, followed by any combination of letters, digits, and underscores; they can be of any length, but only the first 255 characters are significant.

Predefined Conditionals

The following standard conditional symbols are defined:

CategorySymbolDCC32DCC64
Since XE2
DCCOSX
Since XE2
DCCOSX64
Since 10.3 Rio Release 2
DCCIOSARM
Since XE3
DCCIOS32
Since XE3
DCCAARM
In XE5
DCCIOSARM64
Since XE8
DCCLINUX64
Since 10.2 Tokyo
DCCAARM64
Since 10.3 Rio Release 3
Comments
CompilerDCCDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINED
VER340
For a list of compiler versions, see Compiler Versions.
DEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDFor Delphi Sydney, compiler version 34.0 has VER340 defined.
PlatformCONSOLEDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDefined if an application is being compiled as a console application.
IOSnot definednot definednot definednot definedDEFINEDDEFINEDN/ADEFINEDnot definednot definedDefined if the target platform is iOS.
*New* in XE4/iOS.
IOS32not definednot definednot definednot definedDEFINEDDEFINEDnot definednot definednot definednot definedDefined if the target platform is iOS32.
Since XE8/iOSarm64.
IOS64not definednot definednot definednot definednot definednot definednot definedDEFINEDnot definednot definedDefined if the target platform is iOS64.
Since XE8/iOSarm64.
NATIVECODEDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDSince Delphi.Net
MSWINDOWSDEFINEDDEFINEDnot definednot definednot definednot definednot definednot definednot definednot definedIndicates that the operating environment is Windows. Use MSWINDOWS to test for any flavor of the Windows platform instead of WIN32.
WIN32DEFINEDnot definednot definednot definednot definednot definednot definednot definednot definednot definedTarget platform is the native 32-bit Windows platform.
WIN64not definedDEFINEDnot definednot definednot definednot definednot definednot definednot definednot definedTarget platform is 64-bit Windows.
*New* in XE2/x64.
MACOSnot definednot definedDEFINEDDEFINEDDEFINEDDEFINEDnot definedDEFINEDnot definednot definedTarget platform is macOS.
*New* in XE2/macOS.
MACOS32not definednot definedDEFINEDnot definedDEFINEDDEFINEDnot definednot definednot definednot definedTarget platform is 32-bit macOS.
*New* in XE2/macOS.
MACOS64not definednot definednot definedDEFINEDnot definednot definednot definedDEFINEDnot definednot definedTarget platform is 64-bit macOS.
*New* in XE8/macOS.
LINUXnot definednot definednot definednot definednot definednot definednot definednot definedDEFINEDnot definedSince Kylix.
LINUX32not definednot definednot definednot definednot definednot definednot definednot definednot definednot definedSince Kylix.
LINUX64not definednot definednot definednot definednot definednot definednot definednot definedDEFINEDnot definedNew in 10.2
POSIXnot definednot definedDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDSince Kylix.
POSIX32not definednot definedDEFINEDnot definedDEFINEDDEFINEDDEFINEDDEFINEDnot definednot definedSince Kylix.
POSIX64not definednot definednot definedDEFINEDnot definednot definednot definedDEFINEDDEFINEDDEFINEDSince Kylix.
ANDROIDnot definednot definednot definednot definednot definednot definedDEFINEDnot definednot definedDEFINEDDefined if the target platform is Android.
*New* in XE5.
ANDROID32not definednot definednot definednot definednot definednot definedDEFINEDnot definednot definednot definedSince XE8/iOSarm64.
ANDROID64not definednot definednot definednot definednot definednot definednot definednot definednot definedDEFINEDDelphi compiler for Android 64-bit platform.
*New* in 10.3.3.
CPUCPU386DEFINEDnot definedDEFINEDDEFINEDnot definedDEFINEDnot definednot definednote definednot definedIndicates that the CPU is an Intel 386 or later.
CPUX86DEFINEDnot definedDEFINEDnot definednot definedDEFINEDnot definednot definednot definednot definedCPU is an Intel 386 or later on any platform.
*New* in XE2/x64.
CPUX64not definedDEFINEDnot definedDEFINEDnot definednot definednot definednot definedDEFINEDnot definedThe CPU supports the x86-64 instruction set, and is in a 64-bit environment.
*New* in XE2/x64.
CPU32BITSDEFINEDnot definedDEFINEDnot definedDEFINEDDEFINEDDEFINEDnot definednot definednot definedThe CPU is in a 32-bit environment, such as DCC32.EXE.
*New* in XE8.
CPU64BITSnot definedDEFINEDnot definedDEFINEDnot definednot definednot definedDEFINEDDEFINEDDEFINEDThe CPU is in a 64-bit environment, such as DCC64.EXE.
*New* in XE8.
CPUARMnot definednot definednot definednot definedDEFINEDnot definedDEFINEDDEFINEDnot definedDEFINEDDefined if the CPU is based on the ARM architecture, such as the Delphi mobile compiler for the iOS device (DCCIOSARM.EXE).
*New* in XE4/iOS.
CPUARM32not definednot definednot definednot definedDEFINEDnot definedDEFINEDnot definednot definednot definedThe CPU is in a 32-bit ARM environment, such as DCCIOSARM.EXE.
*New* in XE8.
CPUARM64not definednot definednot definednot definednot definednot definednot definedDEFINEDnot definedDEFINEDThe CPU is in a 64-bit ARM environment, such as DCCIOSARM64.EXE.
*New* in XE8.
Availability
ALIGN_STACKnot definednot definedDEFINEDnot definednot definedDEFINEDnot definednot definednot definednot definedDefined in code that may be shared with the macOS compiler and another compiler on another platform such as Linux that does not have a rigid stack alignment requirement. For more information, see Eli Boling's blog at http://blogs.embarcadero.com/eboling/2009/05/20/5607 .
*New* in XE2/macOS.
ASSEMBLERDEFINEDDEFINEDDEFINEDnot definednot definedDEFINEDnot definednot definednot definednot definedAssembler syntax is accepted.
AUTOREFCOUNT (*)not definednot definednot definedDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINED if 10.2.
Not defined since 10.3.
not definedDefined for compilers that use automatic reference counting, such as the Delphi mobile compilers.
*New* in XE4/iOS. Removed in 10.4 Sydney.
EXTERNALLINKERnot definednot definednot definedDEFINEDDEFINEDnot definedDEFINEDDEFINEDDEFINEDDEFINEDDefined for compilers that have an external linker and the LLVM code generator; the Delphi mobile compilers have the external ld linker and use LLVM as code generator.
*New* in XE4/iOS.
UNICODEDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDUNICODE is defined as the default string type.
CONDITIONALEXPRESSIONSDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDTests for the use of the $IF directive.
ELFnot definednot definednot definednot definednot definednot definednot definednot definedDEFINEDnot definedDefined when targeting Executable and Linkable Format (ELF) files.
NEXTGEN (*)not definednot definednot definedDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINED if 10.2.
Not defined since 10.3.
not definedDefined for compilers (such as the Delphi mobile compilers) that use 'next-generation' language features, such as 0-based strings.
*New* in XE4/iOS. Removed in 10.4 Sydney.
PC_MAPPED_EXCEPTIONSnot definednot definedDEFINEDnot definednot definedDEFINEDnot definednot definednot definednot definedDefined when compiling on a platform or for a target platform that uses address maps instead of stack frames to unwind exceptions (such as macOS).
*New* in XE2.
PICneverneveralways DEFINEDalways DEFINEDalways DEFINEDalways DEFINEDalways DEFINEDalways DEFINEDalways DEFINEDalways DEFINEDDefined for platforms that require Position-Independent Code (PIC), such as macOS.
UNDERSCOREIMPORTNAMEDEFINEDnot definedDEFINEDnot definednot definedDEFINEDnot definednot definednot definednot definedDefined for compilers that add a leading underscore (for example, in names of dynamic libraries imported from Mac OS).
*New* in XE4/iOS.
WEAKREFnot definednot definednot definedDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDefined for compilers that can use weak references (the [weak] attribute).
*New* in XE4/iOS.
WEAKINSTREF (*)not definednot definednot definedDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINED if 10.2.
Not defined since 10.3.
not definedDefined when weak references are defined for instances.
*New* in XE4/iOS. Removed in 10.4 Sydney.
WEAKINTFREFnot definednot definednot definedDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDEFINEDDefined when weak references are defined for interfaces.
*New* in XE4/iOS.
Attention: The symbols followed by an asterisk (*) were defined for Delphi mobile compilers in the past, but they have been removed in RAD Studio 10.4 Sydney as part of the removal of the ARC memory model.

In the table column heads:

  • DCC32 is the 32-bit Windows Delphi compiler.
  • DCC64 is the 64-bit Windows Delphi compiler.
  • DCCOSX is the 32-bit macOS Delphi compiler.
  • DCCOSX64 is the 64-bit macOS Delphi compiler.
  • DCCIOSARM is the Delphi compiler for 32-bit iOS Devices.
  • DCCIOS32 is the Delphi compiler for iOS Simulators.
  • DCCAARM.EXE is the Delphi compiler for Android devices.
  • DCCIOSARM64 is the Delphi compiler for 64-bit iOS devices.
  • DCCLINUX64 is the 64-bit Linux Delphi compiler.
  • DCCAARM64.EXE is the Delphi compiler for 64-bit Android devices.

Using Conditional Defines for the Compiler Version

For example, to determine the version of the compiler and run-time library that were used to compile your code, you can use {$IF} with the CompilerVersion, RTLVersion and other constants:

See the table of Compiler Versions for a list of version numbers associated with various released Delphi compilers.

Predefined Constants

Constants can be more powerful than conditionals because you can use constants programmatically in Delphi code. Conditionals, on the other hand, are accepted only inside conditional compiler directives such as {$IF} and {$IFDEF}.

There are three important constants available:

  • System.RTLVersion is a constant defined as the version of the run-time library. For Sydney, RTLVersion is 34.
  • System.CompilerVersion is a constant defined as the version of the current Delphi compiler. For Sydney, CompilerVersion is 34.
  • FMX.Types.FireMonkeyVersion is a constant defined as the version of the current FireMonkey library. For Sydney, FireMonkeyVersion is 270.

See Also

  • CompilerVersion_(Delphi) Code Example
  • IF directive (Delphi) and IFEND directive (Delphi)
  • IFDEF directive (Delphi) and ENDIF directive (Delphi)
  • Delphi Compiler page in Project Options
Retrieved from 'http://docwiki.embarcadero.com/RADStudio/Sydney/e/index.php?title=Conditional_compilation_(Delphi)&oldid=271838'

IMPORTANT! Newer Mac hardware (e.g. T2/M1 chips) do not run Linux well, or at all. This is true for Linux in general, not just Kali Linux.
The model & year of the device will determine how successful your experience will be.

This guide will show you to dual-boot macOS/OS X with Kali Linux using rEFInd boot manager. If you wish to replace macOS/OS X completely, please refer to our single boot Kali on Mac hardware guide.

By using using the 3rd party boot manager rEFInd(a fork of rEFIt) we are able to increase our control when booting over macOS/OS X OS’s default option. This makes it perfect for dual booting, as a keyboard shortcut does not need to be used every time the device is powered on to boot Kali Linux. rEFInd also has the advantage of helping older hardware to boot from USB devices that would not be able to otherwise (e.g. non-EFI). Once Kali Linux has been installed, rEFInd can be customized to be hidden during boot or removed completely.

In our example, we will be installing Kali Linux on a Mac Mini (Mid 2011) using macOS High Sierra (10.13). The same procedure has also been tested on a Mac Book Air (Early 2014) using macOS Catalina (10.15).

Installation Prerequisites

This guide will make the following assumptions:

  • You have read our single boot Kali Linux install guide, as this has the same Installation Prerequisites (System requirements & setup assumptions).
  • When downloading Kali Linux, pick the live image, rather than the installer option.
  • A single disk to install to (rather than a dedicated disk per operating system).
  • Currently running macOS/OS X 10.7 or higher (later versions are more preferred) as this means the hardware is Intel (and not a PowerPC CPU).
  • Depending on the Mac hardware model & year, you may find:
    • Different results when trying to boot by using either a CD/DVD or a USB drive.
      • You may be able to increase the chances of booting (especially older hardware and non-EFI) from a USB drive by having rEFInd pre-installed.
    • When using the graphical installer, you may notice the tracepad does not function (but will after Kali Linux is installed).
    • In-built wireless may not work, as firmware-b43-installer is not included in the default images.

We need to use a different image from the single boot Kali Linux install guide, as we need the live image. This is because we need to edit the disk structure without mounting any partitions (otherwise they would be in-use). After we have finished altering the disk layout, we can still install Kali Linux using the live image, but there will be a few differences such as:

  • Changing or removing the desktop environment.
  • Installing or removing any metapackages.

Both of these can be addressed post installation, as it saves swapping to the installer image (as you will need either multiple CD/DVD/USBs or to re-image half way though).

Targeting change mac os background

This installation has the potential to go wrong very easily as it involves editing existing partitions. Be aware of what partitions you are modifying and where you are installing Kali Linux to.
Having a backup of your macOS/OS X files available is a good idea in the event something goes wrong.

Resize macOS/OS X Procedure

Before we can install Kali Linux, there needs to be room on the hard disk. Depending on the format of the macOS/OS X partition, will depend on what method you need todo.

  • If macOS/OS X Sierra (10.12) and earlier, it will be Mac OS Extended (HFS+).
    • You can resize using GParted in from a Kali Linux live session
  • Since macOS/OS X High Sierra (10.13) and later, the default will be Apple File System (APFS).
    • You can resize in a normal macOS/OS X session, or in recovery mode (recommended).

HFS+/GParted

  1. To start resizing, make sure you insert your Kali Linux installation medium and power on the device. Immediately press and hold the Option (or Alt) ⌥ key until you see the boot menu (rEFInd if installed, else the default macOS/OS X).You may or may not have a Recovery HD depending on your macOS/OS X setup.
  1. When the boot menu appears, if everything works as expected, you should see two volumes:
  • EFI Boot - Newer hardware which support UEFI. It is common for GUID Partition Table (GPT) partitions to be used.
  • Windows - “Non-EFI” boot. This use on older hardware which uses BIOS. You often see Master Boot Record (MBR) partition tables here.

If you only see one volume (EFI Boot), then the installation media is not supported for this device. This could be because the age of the firmware on the device.
You may wish to install rEFInd, as it is a boot manager, and try again.

Even though Kali Linux is based on Debian, macOS/OS X always detects non-EFI boot media as Windows. We suggest that you select the EFI Boot volume to continue. However, if the installation hangs at this point, power cycle and select Windows (Being Kali Linux non-EFI/BIOS). The success depends on the Mac hardware’s model & year.

  1. You should be greeted with the Kali Linux boot screen. Select Live, and you should be booted into the Kali Linux default desktop.
  1. Now launch GParted, which we’ll use to shrink the existing macOS/OS X partition to give us enough room to install Kali Linux in the free space.
  1. Once GParted has opened, select your macOS/OS X partition & resize it leaving enough space (we recommend at least 20 GB) for the Kali Linux installation.

Depending on your setup, it is often the second option (the largest partition). In our example, there are three partitions:

  • The EFI upgrade partition (/dev/sda1)
  • macOS/OS X’s main operating system (/dev/sda2)
  • System Recovery (/dev/sda3)

If you are moving past into any non-white in the partition then you are editing a section that is in use.
Only remove from the area of the partition that is not in use.
It is alright to leave the third partition (/dev/sda3), and only shrink the actual install (/dev/sda2).

If you wish to organize the partition to group all the macOS/OS X partitions together, placing the free space at the end, you may do so.

  1. Once you have resized your macOS/OS X partition, ensure you “Apply All Operations” on the hard disk. Exit gparted and reboot.

APFS/Recovery

This can be doing using either the command line, or graphical (using Disk Utility). Both option support resizing in a “normal” session, or booting into recovery mode. Using recovery mode, means the drive is not in use, so would reduce of the chances of issues. We would also recommend using the command line method, as it allows for a empty partition to be created which simplifies the setup process later on.

  1. To get to command line access: Spotlight->Terminal

  2. By using diskutil list, we can see our disk we want to resize is disk0s2, and it is ~500GB.

  1. We want to reduce the 500GB to be 400GB. This would give Kali Linux 100GB (we recommend at least 20 GB).
  1. Quickly checking diskutil list again, we can see it has been successful.

Kali Linux Installation Procedure

  1. The installation procedure from this point onwards is similar to a Kali Linux Hard Disk install, until the point of the partitioning.At this point, you need to select “Guided - use the largest continuous free space(rather than “Guided - the entire disk”) which got created earlier with gparted.

Mac Os Change Desktop

Do not forget you may need to press and hold the Option (or Alt) ⌥ key during the startup to see the boot menu (unless you have rEFInd installed).

  1. You can carry on following the single boot Kali Linux install guide, expect you will not have the option to select desktop environment or metapackages as you are using the live image. Once the installation is done, reboot.

By default, macOS/OS X will boot into itself, rather than any other operating system/install media. As we have done it already a few times, you need to hold the Option (or Alt) ⌥ key. Whilst this “works”, but its not ideal as it is easy to not boot anything other tha macOS/OS X. Enter rEFInd, a replacement boot manager (which can also have themes applied).

Installing rEFInd

rEFInd is a boot manager, replacing the limiting default one with macOS/OS X, allowing for greater options. It can be installed either before or after Kali Linux’s installation, as well as from macOS/OS X or Kali Linux.

Since the release of macOS/OS X El Capitan (10.11), an additional security feature got introduced, System Integrity Protection (SIP). To install rEFInd using macOS/OS X, this first needs to be one-time bypassed (recommended), or disabled. Alternatively rEFInd can be installed using Kali Linux (we recommended todo so after when Kali Linux is installed rather than using live mode).

Installing rEFInd using macOS/OS X

rEFInd cannot easily be downloaded when in recovery mode, as there is limited space and tools/libraries available (e.g. curl does not support https). As a result, we will download rEFInd inside of a normal macOS/OS X session and afterwards reboot to recovery mode to install.

At the time of this writing, the latest version of rEFInd is 0.12.0.

  1. We will start off by downloading rEFInd, check its a valid zip file, and then extract.
  1. We are going to restarting macOS/OS X, and press the Command (⌘) and R keys at the same time, until you see a boot logo. At this point, if there is a firmware password, you will need to enter it in order to continue.

This will bypass SIP by using macOS/OS X’s Recovery System version which is in-built to the firmware (so no Internet connection is required).

  1. When recovery mode has fully loaded, from the menu: Utilities->Terminal.
  1. Afterwards, we need to navigate to the extracted folder.

The path will be different, as its based on the label of the hard disk (in our case, Macintosh HD) and username (username) and version of rEFInd (0.12.0)

  1. Execute shell script refind-install.

Mac Os Change Folder Color

Even though we are in recovery, where SIP is not running, rEFInd still believes it is. We will overwrite this.

  1. Reboot macOS/OS X. From the menu: Apple->Restart.
  1. Upon restart you should see the new boot manager, rEFInd.

Installing rEFInd using Kali Linux

rEFInd is also included with Kali Linux. We can quickly install it by doing the following:

During the installation, you will get a prompt saying about automatically running rEFInd. We recommend you press yes, otherwise you will need to run sudo dpkg-reconfigure refind (or sudo refind-install) afterwards.

Upon restart you should see the new boot manager, rEFInd.

Configuring rEFInd

If you wish, you can alter rEFInd in various ways now, including:

  • The default OS selection
  • Timeout for menu selection
  • Direct boot into the default OS (Note, by pressing Option (or Alt) ⌥ key during boot, you will have a one-time boot menu).
  • Adding custom icons/themes.

refind.conf

Targeting Change Mac Os Into Windows

macOS/OS X El Capitan

If you wish to make any of these alterations, this can be done by editing rEFInd’s configuration file. If you are using macOS/OS X El Capitan (10.11) or later, you need to mount the EFI boot volume first to access the file. This is done by doing the following.

macOS/OS X Yosemite

If you are using macOS/OS X Yosemite (10.10) or earlier, the configuration file is located here as no mounting is required.

Kali Linux

On Kali Linux, the configuration file is found in the following location.

Post Installation

Now that you’ve completed installing Kali Linux, it’s time to customize your system.

The General Use section has more information and you can also find tips on how to get the most out of Kali Linux in our User Forums.