如何关闭范围检查文件的一部分.关闭是很容易的,但是如何稍后恢复到项目设置?下面的伪代码应该解释一下:
- 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}