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

前端 未结 5 1268
半阙折子戏
半阙折子戏 2021-02-20 00:52

When I use Delphi directives in code, like:

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

Where do I assign the word \'something\' in the project? I tried

5条回答
  •  醉酒成梦
    2021-02-20 01:51

    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 ---

    {$DEFINE Symbol}
    {$IFDEF Symbol}
      {$DEFINE AnotherSymbol}
    {$ENDIF}
    

    In you Delphi modules, where you need to check are symbols defined, put this code in interface section:

    interface
    
    {$I Predefines.inc}
    
    uses ...
    
    // Check you defines
    
    {$IFDEF Symbol}
    ...
    {$ENDIF}
    

提交回复
热议问题