Disabling range checks in Delphi

CodeGear Delphi 2007, 2009
The obvious solution to the problem how to disable range checks in Delphi: {$RANGECHECKS OFF} // code here {$RANGECHECKS ON} Such a snippet will automatically cause the range-checking to suddenly become enabled after running regardless of what it was before, even if it wasn't previously enabled in compiler options or code.
{$R+} is brief notation for {$RANGECHECKS ON} and {$R-} is notation for {$RANGECHECKS OFF} respectively.
Prefer to resort to this crutch construction which does not change the check state in the rest of the project:
{$IFOPT R+} {$DEFINE RANGEON_ON} {$R-} {$ELSE} {$UNDEF RANGEON_ON} {$ENDIF} // // Your code here // {$IFDEF RANGEON_ON} {$R+} {$UNDEF RANGEON_ON} {$ENDIF}

No comments:

Post a Comment