Directives are commands to the compiler such as
{$D+}
or{$WARN xxxx OFF}
. Compiler defined conditionals are not “directives”, rather they’re used for conditional directives{$IF Defined(xxxx)}
or{$IFDEF xxxx}
, where xxxx can beNEXTGEN
– Allen Bauer
It’s important to describe features right so everyone understands what you mean.
And note that you should end all your IFDEF
with IFEND
to stay compatible with the broadest set of Delphi versions possible.
–jeroen
Source: [WayBack] delphi – What is the use of NEXTGEN compiler conditional? – Stack Overflow
PS: Note the comment below by Remy Lebeau:
Note, in Delphi XE3 and later, you might also need to use
{$LEGACYIFEND ON}
(http://docwiki.embarcadero.com/RADStudio/en/Legacy_IFEND_(Delphi)) in order to use{$IFEND}
correctly, particularly if you have nested{$IF}
and{$IF(N)DEF}
blocks in your code.
A quick search for “LEGACYIFEND” “Delphi” “XE3” revealed this directive was indeed introduced in Delphi XE3, but not documented until XE4:
- [WayBack] It’s a blong, blong, blong road…: New compiler directives in Delphi XE3
- [WayBack] Legacy IFEND (Delphi) – RAD Studio XE4
- [Archive.is] Legacy IFEND (Delphi) – RAD Studio XE3
- [WayBack] Fix List for Embarcadero Delphi XE3 and C++Builder XE3 which does document the
--legacy-ifend
command-line switch
Brian Long documents how to get around the limitation that Remy commented about:
{$ifdef CONDITIONALEXPRESSIONS} {$if CompilerVersion >= 24.0} {$LEGACYIFEND ON} {$ifend} {$endif}
It is in fact at the top of [WayBack] indy/IdCompilerDefines.inc at master · graemeg/indy · GitHub, which reminds me that there is now a git mirror of Indy at GitHub:
[WayBack] GitHub – graemeg/indy: Indy (Internet Direct) framework. This is an unofficial mirror repository which gets synced every 15 minutes. It contains the full history from the official Indy 10 SVN repository.
–jeroen