本文介绍了仅针对一小部分代码关闭 Delphi 范围检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何关闭文件一部分的范围检查.关闭很容易,但我以后如何恢复到项目设置?下面的伪代码应该解释一下:
How can one switch off range checking for a part of a file. Switching off is easy, but how do I revert to the project setting later on? The pseudo-code below should explain it:
Unit1;
//here's range checking on or off as per the project setting
code here...
{$R-}
//range checking is off here because the code causes range check errors
code here...
//now I want to revert to the project setting. How do I do that?
code here...
end.
推荐答案
请参阅:IFOPT 指令.
{$IFOPT R+}
{$DEFINE RANGEON}
{$R-}
{$ELSE}
{$UNDEF RANGEON}
{$ENDIF}
//range checking is off here because the code causes range check errors
//code here...
{$IFDEF RANGEON}
{$R+}
{$UNDEF RANGEON}
{$ENDIF}
这篇关于仅针对一小部分代码关闭 Delphi 范围检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!