Disabling overflow checks in Delphi

CodeGear Delphi 2007, 2009
The obvious solution to the problem how to disable overflow checks in Delphi:
{$OVERFLOWCHECKS OFF} // code here {$OVERFLOWCHECKS ON}
Such a snippet will automatically cause the overflow-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.
{$Q+} is brief notation for {$OVERFLOWCHECKS ON} and {$Q-} is notation for {$OVERFLOWCHECKS OFF} respectively.
Prefer to resort to this crutch construction which does not change the check state in the rest of the project:
{$IFOPT Q+} {$DEFINE OVERFLOW_ON} {$Q-} {$ELSE} {$UNDEF OVERFLOW_ON} {$ENDIF} // // Your code here // {$IFDEF OVERFLOW_ON} {$Q+} {$UNDEF OVERFLOW_ON} {$ENDIF}

No comments:

Post a Comment