Getting Started with C language Chapter VIII --C language preprocessor

  For example: #include, this command to the beginning of the called number # preprocessor.

=== C language macro definition (#define usage) ====

  #define command called a macro definition, it is also a commanding C language preprocessor. The so-called macro definition, an identifier is used to represent a string, if there is the identifier in the code behind, then replace all of the specified string.

  #define N 100

  Some explanations for the use of #define

    1. The macro definition is used to represent a string macro name, time and expansion of a macro string to replace the macro name, this is just a simple and crude replacement.

    2. The macro definition is not a description or statement, end of the line does not have to add a semicolon.

    3. The macro definition must uninstall function outside the scope of which is defined macro commands to the source end, such as to the scope which can stop command # undef.

==========================

 

=========== ========= C language conditional compilation

#if #elif #else #endif

Example code:

  #include<stdio.h>

  int main () {

    #if _WIN32

      printf("win32");

    #elif _linux_

      printf ( "linux system");

    #else

      printf ( "qita");

    #endif

    return 0;

  }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

Guess you like

Origin www.cnblogs.com/dagailun/p/12354147.html