关闭Delphi范围检查一小部分代码

前端之家收集整理的这篇文章主要介绍了关闭Delphi范围检查一小部分代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何关闭范围检查文件的一部分.关闭是很容易的,但是如何稍后恢复到项目设置?下面的伪代码应该解释一下:
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 directive.
{$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}
原文链接:https://www.f2er.com/delphi/102626.html

猜你在找的Delphi相关文章