# Define allows you to define symbols. When you use a symbol as the expression passed to the # if Command, the calculation result of this expression is true. # Undef is the opposite. It allows you to cancel the definition of a symbol, so that the expression is calculated as false by using the symbol as an expression in the # if command.
The definition method is keyword + space + symbol to be defined, for example
# Define DEBUG // declarative DEBUG
# Undef DEBUG // Delete the DEBUG symbol
It tells the compiler that there is a given name symbol. In this example, the defined symbol is DEBUG. This is similar to declaring a variable, but the variable itself does not have a real value, but it only exists. This symbol is not part of the actual code, but exists only when the compiler compiles the code. In C # code, it makes no sense.
Note the following three points:
1. If the symbol already exists, the declaration will be meaningless. Similarly, if the symbol does not exist, deleting the page does not work.
2. In addition, the pre-processing command does not need to end with a semicolon. It considers that only one command is available in one line.
3. The declaration must be at the top of the class category.
Xiaotian: What is the purpose of this? Not shown.
This article is a new one. For more information, see the source and author!