The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,418 other followers

Delphi – directives are not conditionals

Posted by jpluimers on 2018/07/03

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

2 Responses to “Delphi – directives are not conditionals”

  1. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: