Delphi Ifdef

Posted on  by admin
Delphi Version Compiler Directives
List Updated 2019 -> http://docwiki.embarcadero.com/RADStudio/Rio/en/Compiler_Versions
{$IFDEF VER80} ShowMessage('Delphi 1');{$ENDIF}
{$IFDEF VER90} ShowMessage('Delphi 2');{$ENDIF}
{$IFDEF VER100} ShowMessage('Delphi 3');{$ENDIF}
{$IFDEF VER120} ShowMessage('Delphi 4');{$ENDIF}
{$IFDEF VER130} ShowMessage('Delphi 5');{$ENDIF}
{$IFDEF VER140} ShowMessage('Delphi 6');{$ENDIF}
{$IFDEF VER150} ShowMessage('Delphi 7');{$ENDIF}
{$IFDEF VER160} ShowMessage('Delphi 8');{$ENDIF}
{$IFDEF VER170} ShowMessage('Delphi 2005');{$ENDIF}
{$IFDEF VER180} ShowMessage('Delphi 2006');{$ENDIF}
{$IFDEF VER185} ShowMessage('Delphi 2007');{$ENDIF}
{$IFDEF VER200} ShowMessage('Delphi 2009');{$ENDIF}
{$IFDEF VER210} ShowMessage('Delphi 2010');{$ENDIF}
{$IFDEF VER220} ShowMessage('Delphi XE');{$ENDIF}
{$IFDEF VER230} ShowMessage('Delphi XE2');{$ENDIF}
{$IFDEF VER240} ShowMessage('Delphi XE3');{$ENDIF}
{$IFDEF VER250} ShowMessage('Delphi XE4');{$ENDIF}
{$IFDEF VER260} ShowMessage('Delphi XE5');{$ENDIF}
{$IFDEF VER270} ShowMessage('Delphi XE6');{$ENDIF}
{$IFDEF VER280} ShowMessage('Delphi XE7');{$ENDIF}
{$IFDEF VER290} ShowMessage('Delphi XE8');{$ENDIF}
{$IFDEF VER300} ShowMessage('Delphi 10 Seattle');{$ENDIF}
{$IFDEF VER310} ShowMessage('Delphi 10.1 Berlin');{$ENDIF}
{$IFDEF VER320} ShowMessage('Delphi 10.2 Tokyo');{$ENDIF}
{$IFDEF VER330} ShowMessage('Delphi 10.3 Rio');{$ENDIF}
if CompilerVersion = 20 then sCompilerName := 'Delphi 2009';
or in conditional compiler expressions:
{$if CompilerVersion > 18} // Delphi 2007 or later {$ifend}
Compiler CompilerVersion Defined Symbol Used BPL
Delphi 10.3 Rio 33 VER330 26
Delphi 10.2 Tokyo 32 VER320 25
Delphi 10.1 Berlin 31 VER310 24
Delphi 10 Seattle 30 VER300 23
Delphi XE8 29 VER290 22
Delphi XE7 28 VER280 21
Delphi XE6 27 VER270 20
Delphi XE5 26 VER260 19
Delphi XE4 25 VER250 18
Delphi XE3 24 VER240 17
Delphi XE2 23 VER230 16
Delphi XE 22 VER220 15
Delphi 2010 21 VER210 14
Delphi 2009 20 VER200 13
Delphi 2007 .NET 19 VER190 12
Delphi 2007 18.5 VER185 12
Delphi 2006 18 VER180
Delphi 2005 17 VER170
Delphi 8 .NET 16 VER160
Delphi 7 15 VER150
Delphi 6 14 VER140
Delphi 5 13 VER130
Delphi 4 12 VER120
Delphi 3 10 VER100
Delphi 2 9 VER90
Delphi 1 8 VER80
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

I have the following code (IP addresses changed) in a Delphi 7 project.

$IfDef starts a conditional compilation section. If Name is defined (by a prior occurrence of $Define), the source code after the $IfDef directive is compiled, up to the corresponding $Else or $EndIf compiler directive. Table 8-1 lists the symbols predefined by the compiler with. Not the answer you're looking for? Browse other questions tagged delphi logical-operators conditional-compilation or ask your own question. Predefined in Delphi. Undefines a compiler directive symbol - as used by IfDef: Author links: Buy Website Traffic at Buywebsitetrafficexperts.com Buy Proxies at.

Under project options:

  • In the 'Directories/Conditionals' tab under the section marked 'Conditionals', I have a single definition: 'DEBUG'.
  • In the 'Version Info' tab under the section marked 'Module Attributes', I have ticked the checkbox labelled 'Debug-build'.

In the above code example, the 'DEBUG' symbol is not defined, so the IP address is set to 123.456.789.12 instead of 127.0.0.1. What am I doing wrong?

This question is following on from Does Delphi's conditional compilation allow the defined symbols to contain values?

Community
Delphi
magnusmagnus

1 Answer

If you compile your project and there are no changes and the DCU is available on the path for the last non debug build then it will be used, causing this problem. Also make sure this unit is included in the uses clause of the DPR.

If you build the project it will force a recompile of all units added to the project.

I generally compile for syntax but always build for testing/deployment.

skamradtskamradt

Not the answer you're looking for? Browse other questions tagged delphidebuggingpreprocessordelphi-7conditional-compilation or ask your own question.