Search code examples
delphiconditional-compilation

Scope of custom definitions


I have a unit which I want to use in two different programs, to tell the difference I wanted to Define a symbol and then check that in the unit.

In my DPR for the project I have;

program Project1;

{$Define MYDEF}  

uses
  Forms,
  ...

and in my Form1 file I have

procedure TForm1.FormCreate(Sender: TObject);
begin
 {$IfDef MYDEF}
   ShowMessage('boo');
 {$EndIf}
end;

however I don't get to see boo! Are definitions limited to a certain scope?


Solution

  • Delphi 2007 and {$IFDEF...} directive, fails to see our conditional

    Under your project add the define to 'Conditional Defines'