home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Programming / C Reference Card 3.0 / C Reference Card / C Reference Card.rsrc / TEXT_413_13.txt < prev    next >
Encoding:
Text File  |  1997-07-17  |  2.7 KB  |  87 lines

  1. PREPROCESSING : commands
  2. _________________________________________________________________________
  3.  
  4.  
  5. PREPROCESSOR COMMANDS
  6.  
  7. #define      Define a preprocessor macro.
  8.  
  9.              Usage: #define MAX 256
  10.                     #define ERROR_STR "\pError, try again."
  11.                     #define MAX(A,B)  ( (A)>(B) ? (A) : (B) )
  12.  
  13. #undef       Remove a preprocessor macro definition.
  14.  
  15.              Usage: #undef MAX
  16.  
  17. #include     Insert text from another source file.
  18.  
  19.              Usage: #include <file>  ->searches 'standard' locations
  20.                     #include "file"  ->searches 'local' locations
  21.  
  22. #if          Conditionally include some text, based on the value of a
  23.              constant expression.
  24.  
  25.              Usage: #if MAX > 256
  26.                       #include "altSize.h"
  27.                     #endif
  28.  
  29. #ifdef       Conditionally include some text, based on whether a macro
  30.              name is defined.
  31.  
  32. #ifndef      Conditionally include some text, based on whether a macro
  33.              name is not defined.
  34.  
  35.              Usage: #ifndef MAX
  36.                       #define MAX 256
  37.                     #endif
  38.  
  39. #else        Alternatively include some text, if the previous #if, 
  40.              #ifdef, #ifndef, or #elif test failed.
  41.  
  42. #endif       Terminate conditional text.
  43.  
  44. #line        Supply a line number for compiler messages.
  45.  
  46. #elif        Alternatively include some text based on the value of
  47.              another constant expression, if the previous #if, #ifdef,
  48.              #ifndef, or #elif test failed.
  49.  
  50.              Usage:  #ifndef OS
  51.                        #define OS MAC
  52.                      #endif
  53.  
  54.                      #if OS == MAC
  55.                        #define SYS_HEADER "MacOS.h"
  56.                      #elif OS == WIN95
  57.                        #define SYS_HEADER "Win95.h"
  58.                      #elif OS == UNIX
  59.                        #define SYS_HEADER "Unix.h"
  60.                      #endif
  61.  
  62. defined      Preprocessor function that yields 1 if a name is defined
  63.              as a preprocessor macro and 0 otherwise; used in #if and 
  64.              #elif statements.  
  65.  
  66.              Usage: #if defined TOKEN -or- #if defined(TOKEN)
  67.  
  68. unary #      Operator to replace macro parameter with a string constant
  69.              containing the parameter's value.
  70.  
  71.              Usage: #define PRINT(a) printf( "value = " #a "\n")
  72.  
  73.              'PRINT(5);' becomes 'printf("value = 5\n");'
  74.  
  75. binary ##    Operator to create a single token out of two adjacent
  76.              tokens.
  77.  
  78.              Usage: #define INPUT(i) input ## i
  79.  
  80.              'INPUT(1) = INPUT(2);' becomes 'temp1 = temp2;'
  81.  
  82. #pragma      Specify implementation-dependent information to the
  83.              compiler.
  84.  
  85. #error       Produce a compile-time error with a designated message.
  86.  
  87.              Usage: #error "Opps! MAX not Defined."