What is the effect of this sentence?
The condition is always false, used to skip some code snippets, to skip the code between #if 0 and #endif at compile time, which causes #if 0---#endif之间的语句不会被编译, which is a precompiled statement.
When commenting out chunks of code, using "#if 0" is better than using "/**/", because the annotation of "/**/" to the large section of the annotation to prevent the annotated code has nested "/**/", which will cause the comment out of the code area is not the scope you want, when the commented out of the big code is very easy to happen, This is especially true after a period of time when the code is modified.
here's how to compile the conditional (#ifdef, #else, #endif, #if等). The following are divided into 3 cases:
1. Situation 1:
#ifdef _xxxx ...
Program Section 1
... #else
... Program Section 2
... #endif
This indicates that the program segment 1 is compiled if the identifier _xxxx has been defined by the #define command, otherwise the program segment 2 is compiled.
Example:
#define NUM
....... .............
.............
num has been defined before #ifdef num printf. :) \ n ");
#else
printf ("There is no definition before Num. :(\ n ");
#endif
}
If the program has #define NUM at the beginning of this line, that is, NUM is defined, and when you encounter #ifdef num below, of course, the first printf is executed. Otherwise, the second printf will be executed.
I think, with this, you can easily turn on/off a specific feature of the entire program.
2: Condition 2:
#ifndef _xxxx
... Program Section 1
... #else
... Program Section 2
... The
#ifndef is used here #endif to indicate if not def. It is, of course, the opposite of #ifdef (if the identifier _xxxx is not defined, then execution Segment 1 is executed, otherwise the Execution Program section 2). The example will not be lifted.
3: Condition 3:
#if constant
... Program Section 1
... #else
... Program Section 2
... #endif
Here, if the constant is true (not 0, whatever the number, as long as it is not 0), execute the program segment
1, otherwise the Execution section 2.
If there are #if need below to write