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

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

    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

提交回复
热议问题