Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I define symbols tested with {$IFDEF}?

When I use Delphi directives in code, like:

{$IFDEF something}
.
.
.
{$ENDIF}

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.

like image 481
dzibul Avatar asked Dec 25 '10 12:12

dzibul


2 Answers

It's in the Conditional Defines slot under Project | Options, which looks like this on D2010:

Delphi Project Options dialog

like image 170
David Heffernan Avatar answered Oct 11 '22 06:10

David Heffernan


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

like image 42
Deltics Avatar answered Oct 11 '22 05:10

Deltics