Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional compilation based on a compiler directive in Delphi 2009

Is there a way in Delphi 2009 to have a section of code conditionally compiled based on a compiler directive. Specifically, I'd like to have code in place that is only included if the range-check compiler directive is turned on.

Something like this:

{$ifdef RANGECHECKINGISON} [do range checking code here] {$endif}

like image 588
Doug Reece Avatar asked Jun 05 '09 18:06

Doug Reece


1 Answers

Use {$ifopt} instead of {$ifdef}:

{$ifopt R+} // if range checking is active
...
{$endif}
like image 181
mghie Avatar answered Sep 19 '22 20:09

mghie