C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
#define
                                             Up Contents Index Back
─────C/C++ Language─────────────────────────────────────────────────────────
 
  Directive:  #define
 
  Syntax:     #define identifier substitution-text
              #define identifier([parameter-list]) substitution-text
 
  Summary:    Replaces all subsequent cases of <identifier> with
              the <substitution-text>.
 
  See also:   defined, #if, #ifdef, #ifndef, #undef, const, inline
 
     The <substitution-text> can consist of one or more constants,
     keywords, or statements. When the identifier is replaced by a
     constant expression, it is a manifest constant. When the
     identifier is replaced by an expression containing parameters, it
     is a macro.
 
     If <substitution-text> is more than one line, it can be continued
     onto successive lines by placing a backslash (\) before the end
     of each line. Enclosing <substitution-text> in parentheses ensures
     proper evaluation if the text is an expression or has a leading
     minus sign. The <substitution-text> can also be empty; this
     removes occurrences of the identifier from the file.
 
     In the following example, a simple manifest constant is created
     by assigning a numeric value to the symbol PI:
 
         #define  PI  3.14159265
 
     If a <parameter-list> appears after the identifier, each
     occurrence of <identifier>(<actual-parameter-list>) is replaced by
     a version of the <substitution-text> that has actual arguments
     substituted for the parameters. There must be an equal number
     of actual arguments and parameters.
 
     The optional <parameter-list> consists of one or more parameter
     names, separated by commas and enclosed by parentheses. No space
     can separate the identifier and the opening parenthesis. The
     parameter names appear in the <substitution-text> to mark the
     places where actual values will be substituted.
 
     In the following example, the macro SQUARE is defined to multiply
     its argument by itself:
 
         #define  SQUARE( arg ) ((arg) * (arg))
 
     In C++, the const keyword and inline functions replace most uses
     of the #define directive.
 
     See: Stringizing Operator
          Charizing Operator
          Token-Pasting Operator
                                    -♦-