Delphi Ifdef
When I use Delphi directives in code, like:
FireMonkey implementation for Linux. Start building UI Linux apps with Embarcadero Delphi and FmxLinux. Download Free Trial v 1.34 Buy Now. Using FmxLinux you focus only on your FMX application and FMXLinux makes it available on Linux. Insidious 3 full movie youtube. Native Look & Feel.
Where do I assign the word 'something' in the project? I tried in some places in project options but it didn't work. Guess I didn't find the correct one.
5 Answers
It's in the Conditional Defines slot under Project Options, which looks like this on D2010:
Other answers have pointed you at the places to define symbols and the scope implications of the different approaches.
However, what no-one has yet mentioned is that if you change the DEFINE symbols you MUST do a FULL BUILD of your project for them to have any effect on your code.
When you 'Compile' the Delphi compiler will only compile units which have themselves changed since the previous compile. If you change DEFINE symbols this doesn't change any project units, so if the units are not re-compiled then the change in DEFINE symbols will not have ANY effect in those units.
To FORCE changes in DEFINE symbols to be applied in ALL units, you MUST 'build', not compile.
This may explain why your attempt to set defines did not appear to work previously
You can also define them in {$DEFINE <symbol>} directives. What changes is the scope. When you define a <symbol> under conditional defines in the project options, the scope is global to the whole project. $DEFINE directives are valid only from the point they are declared to the end of the current module, or until an $UNDEF directive using the same <symbol> is encountered. What to use depends on your needs, and what the IFDEF does.
Ilamai Itho Itho Sakala Kalaa Vallavan () 13. Senorita Johnny () 15. Spb hindi hits mp3 juke. Uchi Vagunthathu Rosapoo Ravikaikari () 14.
There are two places where you can put conditional defines that are used in all units of a project:
- in the project options (as David Heffernan already said)
- in an include file that is included in all of these units
Why do I mention the second option? Because it allows specialized processing based on the VERxxx conditional define and other conditional defines given in 1. See jedi.inc (from the Jedi JCL) for an example.
Also, as Deltics said: When it determines which units to recompile, the compiler only checks whether the unit itself has changed, not whether the conditional defines or any include files have changed. So if you change conditional defines, you must do a rebuild, not just a recompile. Since the Delphi compiler is very fast, this fortunately does not make much of a difference for compile times.
You can define global symbols in external file with .inc extension.Create a new text file, put in it all you defines and save it as for instance Predefines.inc:
--- Content of the file Predefines.inc ---
In you Delphi modules, where you need to check are symbols defined, put this code in interface section:
Not the answer you're looking for? Browse other questions tagged delphidelphi-2009compiler-directives or ask your own question.
| 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 |