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}