基于Delphi 2009中的编译器指令的条件编译

时间:2021-09-02 11:50:08

Is there a way in Delphi 2009 to have a section of code conditionally compiled based on a compiler directive. Specifically, I'd like to have code in place that is only included if the range-check compiler directive is turned on.

在Delphi 2009中是否有一种方法可以根据编译器指令有条件地编译一段代码。具体来说,我希望只有在打开范围检查编译器指令时才包含代码。

Something like this:

像这样的东西:

{$ifdef RANGECHECKINGISON} [do range checking code here] {$endif}

{$ ifdef RANGECHECKINGISON} [在这里做范围检查代码] {$ endif}

1 个解决方案

#1


Use {$ifopt} instead of {$ifdef}:

使用{$ ifopt}而不是{$ ifdef}:

{$ifopt R+} // if range checking is active
...
{$endif}

#1


Use {$ifopt} instead of {$ifdef}:

使用{$ ifopt}而不是{$ ifdef}:

{$ifopt R+} // if range checking is active
...
{$endif}