delphi - 仅关闭一小部分代码的 Delphi 范围检查

标签 delphi project-settings range-checking

如何关闭对文件一部分的范围检查。关闭很容易,但稍后如何恢复到项目设置?下面的伪代码应该解释它:

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}

关于delphi - 仅关闭一小部分代码的 Delphi 范围检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4997911/

相关文章:

delphi - 如何使用 CryptoAPI 加载 OpenSSL 生成的 RSA1024 纯文本公钥?

c - Eclipse 项目设置未转移到新项目

ipad - 想要从通用应用程序降级为仅 iPad 应用程序

linux - 计算常量时出现范围检查错误

java - 如何确定一周中周五和周日之间特定时间的日期

delphi - 如何使用纯 GDI 对 Canvas 区域进行颜色混合(按指定的 alpha 值着色)?

delphi - 关于实用的用户身份验证系统的建议?

delphi - DLL 中的 FMX 形式 (firemonkey/delphi)