Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1445

Delphi – directives are not conditionals

$
0
0

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 be NEXTGEN – 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: [WayBackdelphi – 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:

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


Viewing all articles
Browse latest Browse all 1445

Trending Articles