There are conditional compilation directives in the C language, which are common:
#define Defining macros
#undef to cancel a defined macro
#if if the given condition is true, compile the following code
#ifdef If the macro is already 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, then compiling the following code is actually the shorthand for the else if
#endif end an # if ... #else条件编译块
#error stop compiling and display an error message
#if 0 .... #endif example
#include <stdio.h>int main () {#if 0printf ("This is never here!\n"); #endifprintf ("#if ... #endif statements are never executed! \ n "); return 0;}
When it comes to C-language projects, someone might notice that there is a statement like # 0 in it, since the statement inside will never be executed, why leave this code behind?
Look at the following example:
#include <stdio.h>int main{/* int a=1; /*int b=2;*/ int c=3; */return 0; }
This code will be compiled with an error, because/*//with the nearest match, so an error occurred. Use # if 0 ... #endif can be used to avoid this error while leaving the code temporarily unused, but potentially valuable.
# if # 0 in the C language