In C,
The Conditional compilation command determines which code is compiled and which are not compiled. You can determine the compilation conditions based on the expression value or whether a specific macro is defined.
The following are some pre-processing commands:
Command usage
# Empty command, no effect
# Include contains a source code file
# Define definition macro
# Undef cancel a defined macro
# If the given condition is true, compile the following code
# Ifdef if the macro has been defined, compile the following code
# Ifndef if the macro is not defined, compile the following code
# Elif if the previous # if given condition is not true and the current condition is true, compile the following code:
# Endif end one. # if ...... # Else Conditional compilation Block
# Error stops compilation and displays error information
1. # if command
# The if command detects the constant expression following it. if the expression is true, compile the code after it until # else, # elif, or # endif appears. Otherwise, the Code is not compiled.
2. # endif command
# Endif is used to terminate # if preprocessing command.
# Include <stdio. h> DEBUG 0 DEBUG
If the # define statement is removed, the effect is the same.
3. # ifdef and # ifndef
# Include <stdio. h> DEBUG
4. # else command
# When the else command is used after a # if Command and the current # if command condition is not true, the code after # else is compiled. # The endif command terminates the preceding condition block.
# Include <stdio. h> DEBUG
5. # elif command
# Elif preprocessing commands combine the functions of # else and # if commands.
# Include <stdio. h> TWO defined TWO