Because for a largeProgramWe may need to define many constants (whether in the source file or header file), so when we sometimes consider defining a constant, we must return to check whether the original constant is defined, however, this is very troublesome. the IF Defined Macro provides a solution for this situation. for example:
# Define ....
# Define ....
........
........
# Define a 100
.......
At this point, we should check whether a is defined (assuming we cannot remember this), or we should add the following sentence to a different value:
# If defined
# UNDEF
# Define a 200
# Endif
The preceding statement checks whether a is defined. If it is defined, use the # UNDEF statement to undefined it and redefine a as 200.
Similarly, check whether a is defined:
# Ifndef A // if A is not defined
# Define a 100
# Endif
In the macro used above: # UNDEF is undefined, # ifndef is short for if not defined, that is, if not defined.
This is the unique role of # If defined!