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

前端 未结 5 1337
半阙折子戏
半阙折子戏 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:49

    There are two places where you can put conditional defines that are used in all units of a project:

    1. in the project options (as David Heffernan already said)
    2. 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.

提交回复
热议问题