# If instructions
# If followed by an expression
# If (max = 10) | (max = 20) code... # endif
Its function is: If (max = 10) | (max = 20) is true, then the compiler will compile the code between # If and # endif (Note: It is compiled, not executed !!)
# Use of if defined
# If is followed by a macro.
# If defined (x)... code... # endif
This # If defined, no matter whether the logic of "X" is "true" or "false", it only determines whether the macro definition in front of this program defines the macro "X, if the macro X is defined, the compiler will compile... Code... Otherwise, the middle... Code... Code.
In addition, # If defined (x) can be reversed, and # If! Defined (X)
# Ifdef usage
# Use of ifdef and # Use of if defined () are consistent
# Ifndef and # If! The usage of defined () is consistent.
The last two points are emphasized:
First, these macro definitions only determine whether the code block is compiled!
Second: Don't forget # endif
C development ---- # differences between if, # ifdef and # If defined