Transferred from: http://www.cppblog.com/Joe/archive/2011/05/24/147036.aspx
When commenting out chunks of code, using "#if 0" is better than using "/**/", because a comment with "/**/" to block the commented out code has nested "/**/", which leads to the commented out area of the code that is not what you want, which is easy to do when the commented out code is large. This is especially true after a period of time when the code is modified.
#if 0/#if 1 is nested-supported.
Here you'll find a description of conditional compilation (#ifdef, #else, #endif, #if等). Here are 3 things:
One, 1. Scenario 1:
#ifdef _XXXX
... Program Section 1 ...
#else
... Program Section 2 ...
#endif
This indicates that if the identifier _xxxx has been defined by the # define command, the program Segment 1 is compiled, otherwise the program segment 2 is compiled.
2: Situation 2:
#ifndef _xxxx
... Program Section 1 ...
#else
... Program Section 2 ...
#endif
The #ifndef is used here, which means if not def. Of course it is the opposite of #ifdef (if the identifier _xxxx is not defined, then execute program segment 1, otherwise execute program segment 2).
3: Situation 3:
#if constants
... Program Section 1 ...
#else
... Program Section 2 ...
#endif
This indicates that if the constant is true (not 0, whatever the number, as long as it is not 0), execute program segment 1, otherwise execute program segment 2.
Second, the nesting situation
1. Situation 1
#if constant A
... Program Section 1 ...
#else
#if constant b
... Program Section 2 ...
#else
... Program Section 3 ...
#endif #endif
This indicates that if the constant A is true (not 0, whatever the number, as long as it is not 0), the program segment 1 is executed. When the constant A is 0, the constant B is true, the program segment 2 is executed, when the constant A is 0, and constant b is 0 o'clock, the program segment 3 is executed;