Conditional compilation based on compiler directive in Delphi 2009

Is there a way in Delphi 2009 to have a code section conditionally compiled based on a compiler directive. In particular, I would like to have code in place that is only included if the validation range compiler directive is enabled.

Something like that:

{$ ifdef RANGECHECKINGISON} [range verification code here] {$ ENDIF}

+6
compiler-construction conditional delphi delphi-2009 directive
source share
1 answer

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

 {$ifopt R+} // if range checking is active ... {$endif} 
+16
source share

All Articles