[PHP] Conditional compilation definition in PHP source code, php source code
The mechanism for Compiling different codes and generating different target files according to different situations is called Conditional compilation.
The following pre-processing commands are available: # if, # elif, # else # endif; # ifdef # else # endif
PHP source code:
# Ifdef SERIALIZE_HEADERS // if there is a macro definition SERIALIZE_HEADERS # define VEC_FREE () smart_str_free (& vec_str) // macro definition VEC_FREE () # else // if not # define VEC_FREE () do {} while (0) // macro definition empty operation # endif # ifdef DEBUG // If macro definition DEBUG # define LOG_MSG printf // macro definition LOG_MSG # else // if not # define LOG_MSG (...) // macro defines an empty operation # endif
Exercise:
# If _ WIN32 printf ("windows SYSTEM \ n"); # elif _ linux _ printf ("linux System \ n "); # else printf ("other systems \ n"); # endif # ifdef N printf ("macro definition N \ n "); # else printf ("macro definition N \ n does not exist"); # endif