This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
2.3.2 #if, #elif, #else, #endif
A pp-if-section is used to conditionally include or exclude portions of program text.
- pp-if-section:
- pp-if-group pp-elif-groupsopt pp-else-groupopt pp-endif-line
- pp-if-group:
- #if pp-expression new-line pp-groupopt
- pp-elif-groups
- pp-elif-group
pp-elif-groups pp-elif-group
- pp-elif-group:
- #elif pp-expression new-line groupopt
- pp-else-group:
- #else new-line groupopt
- pp-endif-line
- #endif new-line
The example:
#define Debug
class Class1
{
#if Debug
void Trace(string s) {}
#endif
}
becomes:
class Class1
{
void Trace(string s) {}
}
If sections can nest. Example:
#define Debug // Debugging on
#undef Trace // Tracing off
class PurchaseTransaction
{
void Commit {
#if Debug
CheckConsistency();
#if Trace
WriteToLog(this.ToString());
#endif
#endif
CommitHelper();
}
}