Feels good to give good news for a change. So you're in luck: that functionality is already in there! Now, the documentation isn't up to date, but it does describe one way of doing exactly what you ask: ///#ifdef NAME ... ///#ENDIF will switch on any arbitrary
define name that you specify on your command line. For instance, if your command line was: "-define:test", you could do this:
What isn't documented [yet] is that there is also another variant: ///#IF, which can also do very crude expression comparisons. So if your command line was something like: "-define:test=10", you could have code that does this:
///#IF TEST < 42
The syntax for the new ///#IF directive is:
///#IF NAME[ OP [VALUE]]
If the NAME preprocessor name is not defined, the condition is always false.
The OP operator can be == (converting equal), != (converting not-equal), === (strict equal), !== (strict not-equal), <, >, <=, and >=. The operators <, >, <= and >= will always try converting the value of the preprocessor name and
the VALUE string to type double before doing the comparison. The == and != operators will first do a string compare, and if false, will then try converting the value of the preprocessor name and the VALUE to double and doing a comparison. The === and !== operators
will only do a string comparison.
If the VALUE portion is a string, don't quote it -- its value is simply everything after the operator to the end of the line, with whitespace trimmed from the ends. So if you set your command line to: "-define:arg=yo ho ho and a bottle
of rum" and want to do a comparison, don't quote the string, just go:
///#if arg === yo ho ho and a bottle of rum
If there is no OP or VALUE portion, the ///#if simply tests for the definition of the NAME preprocessor name. Since the DEBUG preprocessor name is already set/reset with the -debug switch, ///#DEBUG is the same as ///#IFDEF DEBUG is the same as ///#IF DEBUG.