When I use Delphi directives in code, like:
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.
The CompilerVersion constant identifies the internal version number of the Delphi compiler. It is defined in the System unit and may be referenced either in code just as any other constant. Description: The $Define compiler directive defines a Symbol.By doing so, the symbol is now On. When a symbol is on, $IfDef will compile conditional code, and $IfNDef.
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. Avatar legend of korra release.
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.
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.
Delphi Define Directive
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:
Xforce keygen 64 bit. Download and Install.net framework 4.5 and directx June 2010 redistributable (NOT from the CD!).
--- Content of the file Predefines.inc ---
In you Delphi modules, where you need to check are symbols defined, put this code in interface section: