Home | History | Annotate | Download | only in info
      1 This is doc/cpp.info, produced by makeinfo version 4.13 from
      2 /Volumes/androidtc/androidtoolchain/./src/build/../gcc/gcc-4.6/gcc/doc/cpp.texi.
      3 
      4 Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
      5 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
      6 2010, 2011 Free Software Foundation, Inc.
      7 
      8    Permission is granted to copy, distribute and/or modify this document
      9 under the terms of the GNU Free Documentation License, Version 1.3 or
     10 any later version published by the Free Software Foundation.  A copy of
     11 the license is included in the section entitled "GNU Free Documentation
     12 License".
     13 
     14    This manual contains no Invariant Sections.  The Front-Cover Texts
     15 are (a) (see below), and the Back-Cover Texts are (b) (see below).
     16 
     17    (a) The FSF's Front-Cover Text is:
     18 
     19    A GNU Manual
     20 
     21    (b) The FSF's Back-Cover Text is:
     22 
     23    You have freedom to copy and modify this GNU Manual, like GNU
     24 software.  Copies published by the Free Software Foundation raise
     25 funds for GNU development.
     26 
     27 INFO-DIR-SECTION Software development
     28 START-INFO-DIR-ENTRY
     29 * Cpp: (cpp).                  The GNU C preprocessor.
     30 END-INFO-DIR-ENTRY
     31 
     32 
     33 File: cpp.info,  Node: Top,  Next: Overview,  Up: (dir)
     34 
     35 The C Preprocessor
     36 ******************
     37 
     38 The C preprocessor implements the macro language used to transform C,
     39 C++, and Objective-C programs before they are compiled.  It can also be
     40 useful on its own.
     41 
     42 * Menu:
     43 
     44 * Overview::
     45 * Header Files::
     46 * Macros::
     47 * Conditionals::
     48 * Diagnostics::
     49 * Line Control::
     50 * Pragmas::
     51 * Other Directives::
     52 * Preprocessor Output::
     53 * Traditional Mode::
     54 * Implementation Details::
     55 * Invocation::
     56 * Environment Variables::
     57 * GNU Free Documentation License::
     58 * Index of Directives::
     59 * Option Index::
     60 * Concept Index::
     61 
     62  --- The Detailed Node Listing ---
     63 
     64 Overview
     65 
     66 * Character sets::
     67 * Initial processing::
     68 * Tokenization::
     69 * The preprocessing language::
     70 
     71 Header Files
     72 
     73 * Include Syntax::
     74 * Include Operation::
     75 * Search Path::
     76 * Once-Only Headers::
     77 * Alternatives to Wrapper #ifndef::
     78 * Computed Includes::
     79 * Wrapper Headers::
     80 * System Headers::
     81 
     82 Macros
     83 
     84 * Object-like Macros::
     85 * Function-like Macros::
     86 * Macro Arguments::
     87 * Stringification::
     88 * Concatenation::
     89 * Variadic Macros::
     90 * Predefined Macros::
     91 * Undefining and Redefining Macros::
     92 * Directives Within Macro Arguments::
     93 * Macro Pitfalls::
     94 
     95 Predefined Macros
     96 
     97 * Standard Predefined Macros::
     98 * Common Predefined Macros::
     99 * System-specific Predefined Macros::
    100 * C++ Named Operators::
    101 
    102 Macro Pitfalls
    103 
    104 * Misnesting::
    105 * Operator Precedence Problems::
    106 * Swallowing the Semicolon::
    107 * Duplication of Side Effects::
    108 * Self-Referential Macros::
    109 * Argument Prescan::
    110 * Newlines in Arguments::
    111 
    112 Conditionals
    113 
    114 * Conditional Uses::
    115 * Conditional Syntax::
    116 * Deleted Code::
    117 
    118 Conditional Syntax
    119 
    120 * Ifdef::
    121 * If::
    122 * Defined::
    123 * Else::
    124 * Elif::
    125 
    126 Implementation Details
    127 
    128 * Implementation-defined behavior::
    129 * Implementation limits::
    130 * Obsolete Features::
    131 * Differences from previous versions::
    132 
    133 Obsolete Features
    134 
    135 * Obsolete Features::
    136 
    137    Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    138 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    139 2010, 2011 Free Software Foundation, Inc.
    140 
    141    Permission is granted to copy, distribute and/or modify this document
    142 under the terms of the GNU Free Documentation License, Version 1.3 or
    143 any later version published by the Free Software Foundation.  A copy of
    144 the license is included in the section entitled "GNU Free Documentation
    145 License".
    146 
    147    This manual contains no Invariant Sections.  The Front-Cover Texts
    148 are (a) (see below), and the Back-Cover Texts are (b) (see below).
    149 
    150    (a) The FSF's Front-Cover Text is:
    151 
    152    A GNU Manual
    153 
    154    (b) The FSF's Back-Cover Text is:
    155 
    156    You have freedom to copy and modify this GNU Manual, like GNU
    157 software.  Copies published by the Free Software Foundation raise
    158 funds for GNU development.
    159 
    160 
    161 File: cpp.info,  Node: Overview,  Next: Header Files,  Prev: Top,  Up: Top
    162 
    163 1 Overview
    164 **********
    165 
    166 The C preprocessor, often known as "cpp", is a "macro processor" that
    167 is used automatically by the C compiler to transform your program
    168 before compilation.  It is called a macro processor because it allows
    169 you to define "macros", which are brief abbreviations for longer
    170 constructs.
    171 
    172    The C preprocessor is intended to be used only with C, C++, and
    173 Objective-C source code.  In the past, it has been abused as a general
    174 text processor.  It will choke on input which does not obey C's lexical
    175 rules.  For example, apostrophes will be interpreted as the beginning of
    176 character constants, and cause errors.  Also, you cannot rely on it
    177 preserving characteristics of the input which are not significant to
    178 C-family languages.  If a Makefile is preprocessed, all the hard tabs
    179 will be removed, and the Makefile will not work.
    180 
    181    Having said that, you can often get away with using cpp on things
    182 which are not C.  Other Algol-ish programming languages are often safe
    183 (Pascal, Ada, etc.) So is assembly, with caution.  `-traditional-cpp'
    184 mode preserves more white space, and is otherwise more permissive.  Many
    185 of the problems can be avoided by writing C or C++ style comments
    186 instead of native language comments, and keeping macros simple.
    187 
    188    Wherever possible, you should use a preprocessor geared to the
    189 language you are writing in.  Modern versions of the GNU assembler have
    190 macro facilities.  Most high level programming languages have their own
    191 conditional compilation and inclusion mechanism.  If all else fails,
    192 try a true general text processor, such as GNU M4.
    193 
    194    C preprocessors vary in some details.  This manual discusses the GNU
    195 C preprocessor, which provides a small superset of the features of ISO
    196 Standard C.  In its default mode, the GNU C preprocessor does not do a
    197 few things required by the standard.  These are features which are
    198 rarely, if ever, used, and may cause surprising changes to the meaning
    199 of a program which does not expect them.  To get strict ISO Standard C,
    200 you should use the `-std=c90', `-std=c99' or `-std=c1x' options,
    201 depending on which version of the standard you want.  To get all the
    202 mandatory diagnostics, you must also use `-pedantic'.  *Note
    203 Invocation::.
    204 
    205    This manual describes the behavior of the ISO preprocessor.  To
    206 minimize gratuitous differences, where the ISO preprocessor's behavior
    207 does not conflict with traditional semantics, the traditional
    208 preprocessor should behave the same way.  The various differences that
    209 do exist are detailed in the section *note Traditional Mode::.
    210 
    211    For clarity, unless noted otherwise, references to `CPP' in this
    212 manual refer to GNU CPP.
    213 
    214 * Menu:
    215 
    216 * Character sets::
    217 * Initial processing::
    218 * Tokenization::
    219 * The preprocessing language::
    220 
    221 
    222 File: cpp.info,  Node: Character sets,  Next: Initial processing,  Up: Overview
    223 
    224 1.1 Character sets
    225 ==================
    226 
    227 Source code character set processing in C and related languages is
    228 rather complicated.  The C standard discusses two character sets, but
    229 there are really at least four.
    230 
    231    The files input to CPP might be in any character set at all.  CPP's
    232 very first action, before it even looks for line boundaries, is to
    233 convert the file into the character set it uses for internal
    234 processing.  That set is what the C standard calls the "source"
    235 character set.  It must be isomorphic with ISO 10646, also known as
    236 Unicode.  CPP uses the UTF-8 encoding of Unicode.
    237 
    238    The character sets of the input files are specified using the
    239 `-finput-charset=' option.
    240 
    241    All preprocessing work (the subject of the rest of this manual) is
    242 carried out in the source character set.  If you request textual output
    243 from the preprocessor with the `-E' option, it will be in UTF-8.
    244 
    245    After preprocessing is complete, string and character constants are
    246 converted again, into the "execution" character set.  This character
    247 set is under control of the user; the default is UTF-8, matching the
    248 source character set.  Wide string and character constants have their
    249 own character set, which is not called out specifically in the
    250 standard.  Again, it is under control of the user.  The default is
    251 UTF-16 or UTF-32, whichever fits in the target's `wchar_t' type, in the
    252 target machine's byte order.(1)  Octal and hexadecimal escape sequences
    253 do not undergo conversion; '\x12' has the value 0x12 regardless of the
    254 currently selected execution character set.  All other escapes are
    255 replaced by the character in the source character set that they
    256 represent, then converted to the execution character set, just like
    257 unescaped characters.
    258 
    259    Unless the experimental `-fextended-identifiers' option is used, GCC
    260 does not permit the use of characters outside the ASCII range, nor `\u'
    261 and `\U' escapes, in identifiers.  Even with that option, characters
    262 outside the ASCII range can only be specified with the `\u' and `\U'
    263 escapes, not used directly in identifiers.
    264 
    265    ---------- Footnotes ----------
    266 
    267    (1) UTF-16 does not meet the requirements of the C standard for a
    268 wide character set, but the choice of 16-bit `wchar_t' is enshrined in
    269 some system ABIs so we cannot fix this.
    270 
    271 
    272 File: cpp.info,  Node: Initial processing,  Next: Tokenization,  Prev: Character sets,  Up: Overview
    273 
    274 1.2 Initial processing
    275 ======================
    276 
    277 The preprocessor performs a series of textual transformations on its
    278 input.  These happen before all other processing.  Conceptually, they
    279 happen in a rigid order, and the entire file is run through each
    280 transformation before the next one begins.  CPP actually does them all
    281 at once, for performance reasons.  These transformations correspond
    282 roughly to the first three "phases of translation" described in the C
    283 standard.
    284 
    285   1. The input file is read into memory and broken into lines.
    286 
    287      Different systems use different conventions to indicate the end of
    288      a line.  GCC accepts the ASCII control sequences `LF', `CR LF' and
    289      `CR' as end-of-line markers.  These are the canonical sequences
    290      used by Unix, DOS and VMS, and the classic Mac OS (before OSX)
    291      respectively.  You may therefore safely copy source code written
    292      on any of those systems to a different one and use it without
    293      conversion.  (GCC may lose track of the current line number if a
    294      file doesn't consistently use one convention, as sometimes happens
    295      when it is edited on computers with different conventions that
    296      share a network file system.)
    297 
    298      If the last line of any input file lacks an end-of-line marker,
    299      the end of the file is considered to implicitly supply one.  The C
    300      standard says that this condition provokes undefined behavior, so
    301      GCC will emit a warning message.
    302 
    303   2. If trigraphs are enabled, they are replaced by their corresponding
    304      single characters.  By default GCC ignores trigraphs, but if you
    305      request a strictly conforming mode with the `-std' option, or you
    306      specify the `-trigraphs' option, then it converts them.
    307 
    308      These are nine three-character sequences, all starting with `??',
    309      that are defined by ISO C to stand for single characters.  They
    310      permit obsolete systems that lack some of C's punctuation to use
    311      C.  For example, `??/' stands for `\', so '??/n' is a character
    312      constant for a newline.
    313 
    314      Trigraphs are not popular and many compilers implement them
    315      incorrectly.  Portable code should not rely on trigraphs being
    316      either converted or ignored.  With `-Wtrigraphs' GCC will warn you
    317      when a trigraph may change the meaning of your program if it were
    318      converted.  *Note Wtrigraphs::.
    319 
    320      In a string constant, you can prevent a sequence of question marks
    321      from being confused with a trigraph by inserting a backslash
    322      between the question marks, or by separating the string literal at
    323      the trigraph and making use of string literal concatenation.
    324      "(??\?)"  is the string `(???)', not `(?]'.  Traditional C
    325      compilers do not recognize these idioms.
    326 
    327      The nine trigraphs and their replacements are
    328 
    329           Trigraph:       ??(  ??)  ??<  ??>  ??=  ??/  ??'  ??!  ??-
    330           Replacement:      [    ]    {    }    #    \    ^    |    ~
    331 
    332   3. Continued lines are merged into one long line.
    333 
    334      A continued line is a line which ends with a backslash, `\'.  The
    335      backslash is removed and the following line is joined with the
    336      current one.  No space is inserted, so you may split a line
    337      anywhere, even in the middle of a word.  (It is generally more
    338      readable to split lines only at white space.)
    339 
    340      The trailing backslash on a continued line is commonly referred to
    341      as a "backslash-newline".
    342 
    343      If there is white space between a backslash and the end of a line,
    344      that is still a continued line.  However, as this is usually the
    345      result of an editing mistake, and many compilers will not accept
    346      it as a continued line, GCC will warn you about it.
    347 
    348   4. All comments are replaced with single spaces.
    349 
    350      There are two kinds of comments.  "Block comments" begin with `/*'
    351      and continue until the next `*/'.  Block comments do not nest:
    352 
    353           /* this is /* one comment */ text outside comment
    354 
    355      "Line comments" begin with `//' and continue to the end of the
    356      current line.  Line comments do not nest either, but it does not
    357      matter, because they would end in the same place anyway.
    358 
    359           // this is // one comment
    360           text outside comment
    361 
    362    It is safe to put line comments inside block comments, or vice versa.
    363 
    364      /* block comment
    365         // contains line comment
    366         yet more comment
    367       */ outside comment
    368 
    369      // line comment /* contains block comment */
    370 
    371    But beware of commenting out one end of a block comment with a line
    372 comment.
    373 
    374       // l.c.  /* block comment begins
    375          oops! this isn't a comment anymore */
    376 
    377    Comments are not recognized within string literals.  "/* blah */" is
    378 the string constant `/* blah */', not an empty string.
    379 
    380    Line comments are not in the 1989 edition of the C standard, but they
    381 are recognized by GCC as an extension.  In C++ and in the 1999 edition
    382 of the C standard, they are an official part of the language.
    383 
    384    Since these transformations happen before all other processing, you
    385 can split a line mechanically with backslash-newline anywhere.  You can
    386 comment out the end of a line.  You can continue a line comment onto the
    387 next line with backslash-newline.  You can even split `/*', `*/', and
    388 `//' onto multiple lines with backslash-newline.  For example:
    389 
    390      /\
    391      *
    392      */ # /*
    393      */ defi\
    394      ne FO\
    395      O 10\
    396      20
    397 
    398 is equivalent to `#define FOO 1020'.  All these tricks are extremely
    399 confusing and should not be used in code intended to be readable.
    400 
    401    There is no way to prevent a backslash at the end of a line from
    402 being interpreted as a backslash-newline.  This cannot affect any
    403 correct program, however.
    404 
    405 
    406 File: cpp.info,  Node: Tokenization,  Next: The preprocessing language,  Prev: Initial processing,  Up: Overview
    407 
    408 1.3 Tokenization
    409 ================
    410 
    411 After the textual transformations are finished, the input file is
    412 converted into a sequence of "preprocessing tokens".  These mostly
    413 correspond to the syntactic tokens used by the C compiler, but there are
    414 a few differences.  White space separates tokens; it is not itself a
    415 token of any kind.  Tokens do not have to be separated by white space,
    416 but it is often necessary to avoid ambiguities.
    417 
    418    When faced with a sequence of characters that has more than one
    419 possible tokenization, the preprocessor is greedy.  It always makes
    420 each token, starting from the left, as big as possible before moving on
    421 to the next token.  For instance, `a+++++b' is interpreted as
    422 `a ++ ++ + b', not as `a ++ + ++ b', even though the latter
    423 tokenization could be part of a valid C program and the former could
    424 not.
    425 
    426    Once the input file is broken into tokens, the token boundaries never
    427 change, except when the `##' preprocessing operator is used to paste
    428 tokens together.  *Note Concatenation::.  For example,
    429 
    430      #define foo() bar
    431      foo()baz
    432           ==> bar baz
    433      _not_
    434           ==> barbaz
    435 
    436    The compiler does not re-tokenize the preprocessor's output.  Each
    437 preprocessing token becomes one compiler token.
    438 
    439    Preprocessing tokens fall into five broad classes: identifiers,
    440 preprocessing numbers, string literals, punctuators, and other.  An
    441 "identifier" is the same as an identifier in C: any sequence of
    442 letters, digits, or underscores, which begins with a letter or
    443 underscore.  Keywords of C have no significance to the preprocessor;
    444 they are ordinary identifiers.  You can define a macro whose name is a
    445 keyword, for instance.  The only identifier which can be considered a
    446 preprocessing keyword is `defined'.  *Note Defined::.
    447 
    448    This is mostly true of other languages which use the C preprocessor.
    449 However, a few of the keywords of C++ are significant even in the
    450 preprocessor.  *Note C++ Named Operators::.
    451 
    452    In the 1999 C standard, identifiers may contain letters which are not
    453 part of the "basic source character set", at the implementation's
    454 discretion (such as accented Latin letters, Greek letters, or Chinese
    455 ideograms).  This may be done with an extended character set, or the
    456 `\u' and `\U' escape sequences.  The implementation of this feature in
    457 GCC is experimental; such characters are only accepted in the `\u' and
    458 `\U' forms and only if `-fextended-identifiers' is used.
    459 
    460    As an extension, GCC treats `$' as a letter.  This is for
    461 compatibility with some systems, such as VMS, where `$' is commonly
    462 used in system-defined function and object names.  `$' is not a letter
    463 in strictly conforming mode, or if you specify the `-$' option.  *Note
    464 Invocation::.
    465 
    466    A "preprocessing number" has a rather bizarre definition.  The
    467 category includes all the normal integer and floating point constants
    468 one expects of C, but also a number of other things one might not
    469 initially recognize as a number.  Formally, preprocessing numbers begin
    470 with an optional period, a required decimal digit, and then continue
    471 with any sequence of letters, digits, underscores, periods, and
    472 exponents.  Exponents are the two-character sequences `e+', `e-', `E+',
    473 `E-', `p+', `p-', `P+', and `P-'.  (The exponents that begin with `p'
    474 or `P' are new to C99.  They are used for hexadecimal floating-point
    475 constants.)
    476 
    477    The purpose of this unusual definition is to isolate the preprocessor
    478 from the full complexity of numeric constants.  It does not have to
    479 distinguish between lexically valid and invalid floating-point numbers,
    480 which is complicated.  The definition also permits you to split an
    481 identifier at any position and get exactly two tokens, which can then be
    482 pasted back together with the `##' operator.
    483 
    484    It's possible for preprocessing numbers to cause programs to be
    485 misinterpreted.  For example, `0xE+12' is a preprocessing number which
    486 does not translate to any valid numeric constant, therefore a syntax
    487 error.  It does not mean `0xE + 12', which is what you might have
    488 intended.
    489 
    490    "String literals" are string constants, character constants, and
    491 header file names (the argument of `#include').(1)  String constants
    492 and character constants are straightforward: "..." or '...'.  In either
    493 case embedded quotes should be escaped with a backslash: '\'' is the
    494 character constant for `''.  There is no limit on the length of a
    495 character constant, but the value of a character constant that contains
    496 more than one character is implementation-defined.  *Note
    497 Implementation Details::.
    498 
    499    Header file names either look like string constants, "...", or are
    500 written with angle brackets instead, <...>.  In either case, backslash
    501 is an ordinary character.  There is no way to escape the closing quote
    502 or angle bracket.  The preprocessor looks for the header file in
    503 different places depending on which form you use.  *Note Include
    504 Operation::.
    505 
    506    No string literal may extend past the end of a line.  Older versions
    507 of GCC accepted multi-line string constants.  You may use continued
    508 lines instead, or string constant concatenation.  *Note Differences
    509 from previous versions::.
    510 
    511    "Punctuators" are all the usual bits of punctuation which are
    512 meaningful to C and C++.  All but three of the punctuation characters in
    513 ASCII are C punctuators.  The exceptions are `@', `$', and ``'.  In
    514 addition, all the two- and three-character operators are punctuators.
    515 There are also six "digraphs", which the C++ standard calls
    516 "alternative tokens", which are merely alternate ways to spell other
    517 punctuators.  This is a second attempt to work around missing
    518 punctuation in obsolete systems.  It has no negative side effects,
    519 unlike trigraphs, but does not cover as much ground.  The digraphs and
    520 their corresponding normal punctuators are:
    521 
    522      Digraph:        <%  %>  <:  :>  %:  %:%:
    523      Punctuator:      {   }   [   ]   #    ##
    524 
    525    Any other single character is considered "other".  It is passed on to
    526 the preprocessor's output unmolested.  The C compiler will almost
    527 certainly reject source code containing "other" tokens.  In ASCII, the
    528 only other characters are `@', `$', ``', and control characters other
    529 than NUL (all bits zero).  (Note that `$' is normally considered a
    530 letter.)  All characters with the high bit set (numeric range
    531 0x7F-0xFF) are also "other" in the present implementation.  This will
    532 change when proper support for international character sets is added to
    533 GCC.
    534 
    535    NUL is a special case because of the high probability that its
    536 appearance is accidental, and because it may be invisible to the user
    537 (many terminals do not display NUL at all).  Within comments, NULs are
    538 silently ignored, just as any other character would be.  In running
    539 text, NUL is considered white space.  For example, these two directives
    540 have the same meaning.
    541 
    542      #define X^@1
    543      #define X 1
    544 
    545 (where `^@' is ASCII NUL).  Within string or character constants, NULs
    546 are preserved.  In the latter two cases the preprocessor emits a
    547 warning message.
    548 
    549    ---------- Footnotes ----------
    550 
    551    (1) The C standard uses the term "string literal" to refer only to
    552 what we are calling "string constants".
    553 
    554 
    555 File: cpp.info,  Node: The preprocessing language,  Prev: Tokenization,  Up: Overview
    556 
    557 1.4 The preprocessing language
    558 ==============================
    559 
    560 After tokenization, the stream of tokens may simply be passed straight
    561 to the compiler's parser.  However, if it contains any operations in the
    562 "preprocessing language", it will be transformed first.  This stage
    563 corresponds roughly to the standard's "translation phase 4" and is what
    564 most people think of as the preprocessor's job.
    565 
    566    The preprocessing language consists of "directives" to be executed
    567 and "macros" to be expanded.  Its primary capabilities are:
    568 
    569    * Inclusion of header files.  These are files of declarations that
    570      can be substituted into your program.
    571 
    572    * Macro expansion.  You can define "macros", which are abbreviations
    573      for arbitrary fragments of C code.  The preprocessor will replace
    574      the macros with their definitions throughout the program.  Some
    575      macros are automatically defined for you.
    576 
    577    * Conditional compilation.  You can include or exclude parts of the
    578      program according to various conditions.
    579 
    580    * Line control.  If you use a program to combine or rearrange source
    581      files into an intermediate file which is then compiled, you can
    582      use line control to inform the compiler where each source line
    583      originally came from.
    584 
    585    * Diagnostics.  You can detect problems at compile time and issue
    586      errors or warnings.
    587 
    588    There are a few more, less useful, features.
    589 
    590    Except for expansion of predefined macros, all these operations are
    591 triggered with "preprocessing directives".  Preprocessing directives
    592 are lines in your program that start with `#'.  Whitespace is allowed
    593 before and after the `#'.  The `#' is followed by an identifier, the
    594 "directive name".  It specifies the operation to perform.  Directives
    595 are commonly referred to as `#NAME' where NAME is the directive name.
    596 For example, `#define' is the directive that defines a macro.
    597 
    598    The `#' which begins a directive cannot come from a macro expansion.
    599 Also, the directive name is not macro expanded.  Thus, if `foo' is
    600 defined as a macro expanding to `define', that does not make `#foo' a
    601 valid preprocessing directive.
    602 
    603    The set of valid directive names is fixed.  Programs cannot define
    604 new preprocessing directives.
    605 
    606    Some directives require arguments; these make up the rest of the
    607 directive line and must be separated from the directive name by
    608 whitespace.  For example, `#define' must be followed by a macro name
    609 and the intended expansion of the macro.
    610 
    611    A preprocessing directive cannot cover more than one line.  The line
    612 may, however, be continued with backslash-newline, or by a block comment
    613 which extends past the end of the line.  In either case, when the
    614 directive is processed, the continuations have already been merged with
    615 the first line to make one long line.
    616 
    617 
    618 File: cpp.info,  Node: Header Files,  Next: Macros,  Prev: Overview,  Up: Top
    619 
    620 2 Header Files
    621 **************
    622 
    623 A header file is a file containing C declarations and macro definitions
    624 (*note Macros::) to be shared between several source files.  You request
    625 the use of a header file in your program by "including" it, with the C
    626 preprocessing directive `#include'.
    627 
    628    Header files serve two purposes.
    629 
    630    * System header files declare the interfaces to parts of the
    631      operating system.  You include them in your program to supply the
    632      definitions and declarations you need to invoke system calls and
    633      libraries.
    634 
    635    * Your own header files contain declarations for interfaces between
    636      the source files of your program.  Each time you have a group of
    637      related declarations and macro definitions all or most of which
    638      are needed in several different source files, it is a good idea to
    639      create a header file for them.
    640 
    641    Including a header file produces the same results as copying the
    642 header file into each source file that needs it.  Such copying would be
    643 time-consuming and error-prone.  With a header file, the related
    644 declarations appear in only one place.  If they need to be changed, they
    645 can be changed in one place, and programs that include the header file
    646 will automatically use the new version when next recompiled.  The header
    647 file eliminates the labor of finding and changing all the copies as well
    648 as the risk that a failure to find one copy will result in
    649 inconsistencies within a program.
    650 
    651    In C, the usual convention is to give header files names that end
    652 with `.h'.  It is most portable to use only letters, digits, dashes, and
    653 underscores in header file names, and at most one dot.
    654 
    655 * Menu:
    656 
    657 * Include Syntax::
    658 * Include Operation::
    659 * Search Path::
    660 * Once-Only Headers::
    661 * Alternatives to Wrapper #ifndef::
    662 * Computed Includes::
    663 * Wrapper Headers::
    664 * System Headers::
    665 
    666 
    667 File: cpp.info,  Node: Include Syntax,  Next: Include Operation,  Up: Header Files
    668 
    669 2.1 Include Syntax
    670 ==================
    671 
    672 Both user and system header files are included using the preprocessing
    673 directive `#include'.  It has two variants:
    674 
    675 `#include <FILE>'
    676      This variant is used for system header files.  It searches for a
    677      file named FILE in a standard list of system directories.  You can
    678      prepend directories to this list with the `-I' option (*note
    679      Invocation::).
    680 
    681 `#include "FILE"'
    682      This variant is used for header files of your own program.  It
    683      searches for a file named FILE first in the directory containing
    684      the current file, then in the quote directories and then the same
    685      directories used for `<FILE>'.  You can prepend directories to the
    686      list of quote directories with the `-iquote' option.
    687 
    688    The argument of `#include', whether delimited with quote marks or
    689 angle brackets, behaves like a string constant in that comments are not
    690 recognized, and macro names are not expanded.  Thus, `#include <x/*y>'
    691 specifies inclusion of a system header file named `x/*y'.
    692 
    693    However, if backslashes occur within FILE, they are considered
    694 ordinary text characters, not escape characters.  None of the character
    695 escape sequences appropriate to string constants in C are processed.
    696 Thus, `#include "x\n\\y"' specifies a filename containing three
    697 backslashes.  (Some systems interpret `\' as a pathname separator.  All
    698 of these also interpret `/' the same way.  It is most portable to use
    699 only `/'.)
    700 
    701    It is an error if there is anything (other than comments) on the line
    702 after the file name.
    703 
    704 
    705 File: cpp.info,  Node: Include Operation,  Next: Search Path,  Prev: Include Syntax,  Up: Header Files
    706 
    707 2.2 Include Operation
    708 =====================
    709 
    710 The `#include' directive works by directing the C preprocessor to scan
    711 the specified file as input before continuing with the rest of the
    712 current file.  The output from the preprocessor contains the output
    713 already generated, followed by the output resulting from the included
    714 file, followed by the output that comes from the text after the
    715 `#include' directive.  For example, if you have a header file
    716 `header.h' as follows,
    717 
    718      char *test (void);
    719 
    720 and a main program called `program.c' that uses the header file, like
    721 this,
    722 
    723      int x;
    724      #include "header.h"
    725 
    726      int
    727      main (void)
    728      {
    729        puts (test ());
    730      }
    731 
    732 the compiler will see the same token stream as it would if `program.c'
    733 read
    734 
    735      int x;
    736      char *test (void);
    737 
    738      int
    739      main (void)
    740      {
    741        puts (test ());
    742      }
    743 
    744    Included files are not limited to declarations and macro definitions;
    745 those are merely the typical uses.  Any fragment of a C program can be
    746 included from another file.  The include file could even contain the
    747 beginning of a statement that is concluded in the containing file, or
    748 the end of a statement that was started in the including file.  However,
    749 an included file must consist of complete tokens.  Comments and string
    750 literals which have not been closed by the end of an included file are
    751 invalid.  For error recovery, they are considered to end at the end of
    752 the file.
    753 
    754    To avoid confusion, it is best if header files contain only complete
    755 syntactic units--function declarations or definitions, type
    756 declarations, etc.
    757 
    758    The line following the `#include' directive is always treated as a
    759 separate line by the C preprocessor, even if the included file lacks a
    760 final newline.
    761 
    762 
    763 File: cpp.info,  Node: Search Path,  Next: Once-Only Headers,  Prev: Include Operation,  Up: Header Files
    764 
    765 2.3 Search Path
    766 ===============
    767 
    768 GCC looks in several different places for headers.  On a normal Unix
    769 system, if you do not instruct it otherwise, it will look for headers
    770 requested with `#include <FILE>' in:
    771 
    772      /usr/local/include
    773      LIBDIR/gcc/TARGET/VERSION/include
    774      /usr/TARGET/include
    775      /usr/include
    776 
    777    For C++ programs, it will also look in `/usr/include/g++-v3', first.
    778 In the above, TARGET is the canonical name of the system GCC was
    779 configured to compile code for; often but not always the same as the
    780 canonical name of the system it runs on.  VERSION is the version of GCC
    781 in use.
    782 
    783    You can add to this list with the `-IDIR' command line option.  All
    784 the directories named by `-I' are searched, in left-to-right order,
    785 _before_ the default directories.  The only exception is when `dir' is
    786 already searched by default.  In this case, the option is ignored and
    787 the search order for system directories remains unchanged.
    788 
    789    Duplicate directories are removed from the quote and bracket search
    790 chains before the two chains are merged to make the final search chain.
    791 Thus, it is possible for a directory to occur twice in the final search
    792 chain if it was specified in both the quote and bracket chains.
    793 
    794    You can prevent GCC from searching any of the default directories
    795 with the `-nostdinc' option.  This is useful when you are compiling an
    796 operating system kernel or some other program that does not use the
    797 standard C library facilities, or the standard C library itself.  `-I'
    798 options are not ignored as described above when `-nostdinc' is in
    799 effect.
    800 
    801    GCC looks for headers requested with `#include "FILE"' first in the
    802 directory containing the current file, then in the directories as
    803 specified by `-iquote' options, then in the same places it would have
    804 looked for a header requested with angle brackets.  For example, if
    805 `/usr/include/sys/stat.h' contains `#include "types.h"', GCC looks for
    806 `types.h' first in `/usr/include/sys', then in its usual search path.
    807 
    808    `#line' (*note Line Control::) does not change GCC's idea of the
    809 directory containing the current file.
    810 
    811    You may put `-I-' at any point in your list of `-I' options.  This
    812 has two effects.  First, directories appearing before the `-I-' in the
    813 list are searched only for headers requested with quote marks.
    814 Directories after `-I-' are searched for all headers.  Second, the
    815 directory containing the current file is not searched for anything,
    816 unless it happens to be one of the directories named by an `-I' switch.
    817 `-I-' is deprecated, `-iquote' should be used instead.
    818 
    819    `-I. -I-' is not the same as no `-I' options at all, and does not
    820 cause the same behavior for `<>' includes that `""' includes get with
    821 no special options.  `-I.' searches the compiler's current working
    822 directory for header files.  That may or may not be the same as the
    823 directory containing the current file.
    824 
    825    If you need to look for headers in a directory named `-', write
    826 `-I./-'.
    827 
    828    There are several more ways to adjust the header search path.  They
    829 are generally less useful.  *Note Invocation::.
    830 
    831 
    832 File: cpp.info,  Node: Once-Only Headers,  Next: Alternatives to Wrapper #ifndef,  Prev: Search Path,  Up: Header Files
    833 
    834 2.4 Once-Only Headers
    835 =====================
    836 
    837 If a header file happens to be included twice, the compiler will process
    838 its contents twice.  This is very likely to cause an error, e.g. when
    839 the compiler sees the same structure definition twice.  Even if it does
    840 not, it will certainly waste time.
    841 
    842    The standard way to prevent this is to enclose the entire real
    843 contents of the file in a conditional, like this:
    844 
    845      /* File foo.  */
    846      #ifndef FILE_FOO_SEEN
    847      #define FILE_FOO_SEEN
    848 
    849      THE ENTIRE FILE
    850 
    851      #endif /* !FILE_FOO_SEEN */
    852 
    853    This construct is commonly known as a "wrapper #ifndef".  When the
    854 header is included again, the conditional will be false, because
    855 `FILE_FOO_SEEN' is defined.  The preprocessor will skip over the entire
    856 contents of the file, and the compiler will not see it twice.
    857 
    858    CPP optimizes even further.  It remembers when a header file has a
    859 wrapper `#ifndef'.  If a subsequent `#include' specifies that header,
    860 and the macro in the `#ifndef' is still defined, it does not bother to
    861 rescan the file at all.
    862 
    863    You can put comments outside the wrapper.  They will not interfere
    864 with this optimization.
    865 
    866    The macro `FILE_FOO_SEEN' is called the "controlling macro" or
    867 "guard macro".  In a user header file, the macro name should not begin
    868 with `_'.  In a system header file, it should begin with `__' to avoid
    869 conflicts with user programs.  In any kind of header file, the macro
    870 name should contain the name of the file and some additional text, to
    871 avoid conflicts with other header files.
    872 
    873 
    874 File: cpp.info,  Node: Alternatives to Wrapper #ifndef,  Next: Computed Includes,  Prev: Once-Only Headers,  Up: Header Files
    875 
    876 2.5 Alternatives to Wrapper #ifndef
    877 ===================================
    878 
    879 CPP supports two more ways of indicating that a header file should be
    880 read only once.  Neither one is as portable as a wrapper `#ifndef' and
    881 we recommend you do not use them in new programs, with the caveat that
    882 `#import' is standard practice in Objective-C.
    883 
    884    CPP supports a variant of `#include' called `#import' which includes
    885 a file, but does so at most once.  If you use `#import' instead of
    886 `#include', then you don't need the conditionals inside the header file
    887 to prevent multiple inclusion of the contents.  `#import' is standard
    888 in Objective-C, but is considered a deprecated extension in C and C++.
    889 
    890    `#import' is not a well designed feature.  It requires the users of
    891 a header file to know that it should only be included once.  It is much
    892 better for the header file's implementor to write the file so that users
    893 don't need to know this.  Using a wrapper `#ifndef' accomplishes this
    894 goal.
    895 
    896    In the present implementation, a single use of `#import' will
    897 prevent the file from ever being read again, by either `#import' or
    898 `#include'.  You should not rely on this; do not use both `#import' and
    899 `#include' to refer to the same header file.
    900 
    901    Another way to prevent a header file from being included more than
    902 once is with the `#pragma once' directive.  If `#pragma once' is seen
    903 when scanning a header file, that file will never be read again, no
    904 matter what.
    905 
    906    `#pragma once' does not have the problems that `#import' does, but
    907 it is not recognized by all preprocessors, so you cannot rely on it in
    908 a portable program.
    909 
    910 
    911 File: cpp.info,  Node: Computed Includes,  Next: Wrapper Headers,  Prev: Alternatives to Wrapper #ifndef,  Up: Header Files
    912 
    913 2.6 Computed Includes
    914 =====================
    915 
    916 Sometimes it is necessary to select one of several different header
    917 files to be included into your program.  They might specify
    918 configuration parameters to be used on different sorts of operating
    919 systems, for instance.  You could do this with a series of conditionals,
    920 
    921      #if SYSTEM_1
    922      # include "system_1.h"
    923      #elif SYSTEM_2
    924      # include "system_2.h"
    925      #elif SYSTEM_3
    926      ...
    927      #endif
    928 
    929    That rapidly becomes tedious.  Instead, the preprocessor offers the
    930 ability to use a macro for the header name.  This is called a "computed
    931 include".  Instead of writing a header name as the direct argument of
    932 `#include', you simply put a macro name there instead:
    933 
    934      #define SYSTEM_H "system_1.h"
    935      ...
    936      #include SYSTEM_H
    937 
    938 `SYSTEM_H' will be expanded, and the preprocessor will look for
    939 `system_1.h' as if the `#include' had been written that way originally.
    940 `SYSTEM_H' could be defined by your Makefile with a `-D' option.
    941 
    942    You must be careful when you define the macro.  `#define' saves
    943 tokens, not text.  The preprocessor has no way of knowing that the macro
    944 will be used as the argument of `#include', so it generates ordinary
    945 tokens, not a header name.  This is unlikely to cause problems if you
    946 use double-quote includes, which are close enough to string constants.
    947 If you use angle brackets, however, you may have trouble.
    948 
    949    The syntax of a computed include is actually a bit more general than
    950 the above.  If the first non-whitespace character after `#include' is
    951 not `"' or `<', then the entire line is macro-expanded like running
    952 text would be.
    953 
    954    If the line expands to a single string constant, the contents of that
    955 string constant are the file to be included.  CPP does not re-examine
    956 the string for embedded quotes, but neither does it process backslash
    957 escapes in the string.  Therefore
    958 
    959      #define HEADER "a\"b"
    960      #include HEADER
    961 
    962 looks for a file named `a\"b'.  CPP searches for the file according to
    963 the rules for double-quoted includes.
    964 
    965    If the line expands to a token stream beginning with a `<' token and
    966 including a `>' token, then the tokens between the `<' and the first
    967 `>' are combined to form the filename to be included.  Any whitespace
    968 between tokens is reduced to a single space; then any space after the
    969 initial `<' is retained, but a trailing space before the closing `>' is
    970 ignored.  CPP searches for the file according to the rules for
    971 angle-bracket includes.
    972 
    973    In either case, if there are any tokens on the line after the file
    974 name, an error occurs and the directive is not processed.  It is also
    975 an error if the result of expansion does not match either of the two
    976 expected forms.
    977 
    978    These rules are implementation-defined behavior according to the C
    979 standard.  To minimize the risk of different compilers interpreting your
    980 computed includes differently, we recommend you use only a single
    981 object-like macro which expands to a string constant.  This will also
    982 minimize confusion for people reading your program.
    983 
    984 
    985 File: cpp.info,  Node: Wrapper Headers,  Next: System Headers,  Prev: Computed Includes,  Up: Header Files
    986 
    987 2.7 Wrapper Headers
    988 ===================
    989 
    990 Sometimes it is necessary to adjust the contents of a system-provided
    991 header file without editing it directly.  GCC's `fixincludes' operation
    992 does this, for example.  One way to do that would be to create a new
    993 header file with the same name and insert it in the search path before
    994 the original header.  That works fine as long as you're willing to
    995 replace the old header entirely.  But what if you want to refer to the
    996 old header from the new one?
    997 
    998    You cannot simply include the old header with `#include'.  That will
    999 start from the beginning, and find your new header again.  If your
   1000 header is not protected from multiple inclusion (*note Once-Only
   1001 Headers::), it will recurse infinitely and cause a fatal error.
   1002 
   1003    You could include the old header with an absolute pathname:
   1004      #include "/usr/include/old-header.h"
   1005    This works, but is not clean; should the system headers ever move,
   1006 you would have to edit the new headers to match.
   1007 
   1008    There is no way to solve this problem within the C standard, but you
   1009 can use the GNU extension `#include_next'.  It means, "Include the
   1010 _next_ file with this name".  This directive works like `#include'
   1011 except in searching for the specified file: it starts searching the
   1012 list of header file directories _after_ the directory in which the
   1013 current file was found.
   1014 
   1015    Suppose you specify `-I /usr/local/include', and the list of
   1016 directories to search also includes `/usr/include'; and suppose both
   1017 directories contain `signal.h'.  Ordinary `#include <signal.h>' finds
   1018 the file under `/usr/local/include'.  If that file contains
   1019 `#include_next <signal.h>', it starts searching after that directory,
   1020 and finds the file in `/usr/include'.
   1021 
   1022    `#include_next' does not distinguish between `<FILE>' and `"FILE"'
   1023 inclusion, nor does it check that the file you specify has the same
   1024 name as the current file.  It simply looks for the file named, starting
   1025 with the directory in the search path after the one where the current
   1026 file was found.
   1027 
   1028    The use of `#include_next' can lead to great confusion.  We
   1029 recommend it be used only when there is no other alternative.  In
   1030 particular, it should not be used in the headers belonging to a specific
   1031 program; it should be used only to make global corrections along the
   1032 lines of `fixincludes'.
   1033 
   1034 
   1035 File: cpp.info,  Node: System Headers,  Prev: Wrapper Headers,  Up: Header Files
   1036 
   1037 2.8 System Headers
   1038 ==================
   1039 
   1040 The header files declaring interfaces to the operating system and
   1041 runtime libraries often cannot be written in strictly conforming C.
   1042 Therefore, GCC gives code found in "system headers" special treatment.
   1043 All warnings, other than those generated by `#warning' (*note
   1044 Diagnostics::), are suppressed while GCC is processing a system header.
   1045 Macros defined in a system header are immune to a few warnings wherever
   1046 they are expanded.  This immunity is granted on an ad-hoc basis, when
   1047 we find that a warning generates lots of false positives because of
   1048 code in macros defined in system headers.
   1049 
   1050    Normally, only the headers found in specific directories are
   1051 considered system headers.  These directories are determined when GCC
   1052 is compiled.  There are, however, two ways to make normal headers into
   1053 system headers.
   1054 
   1055    The `-isystem' command line option adds its argument to the list of
   1056 directories to search for headers, just like `-I'.  Any headers found
   1057 in that directory will be considered system headers.
   1058 
   1059    All directories named by `-isystem' are searched _after_ all
   1060 directories named by `-I', no matter what their order was on the
   1061 command line.  If the same directory is named by both `-I' and
   1062 `-isystem', the `-I' option is ignored.  GCC provides an informative
   1063 message when this occurs if `-v' is used.
   1064 
   1065    There is also a directive, `#pragma GCC system_header', which tells
   1066 GCC to consider the rest of the current include file a system header,
   1067 no matter where it was found.  Code that comes before the `#pragma' in
   1068 the file will not be affected.  `#pragma GCC system_header' has no
   1069 effect in the primary source file.
   1070 
   1071    On very old systems, some of the pre-defined system header
   1072 directories get even more special treatment.  GNU C++ considers code in
   1073 headers found in those directories to be surrounded by an `extern "C"'
   1074 block.  There is no way to request this behavior with a `#pragma', or
   1075 from the command line.
   1076 
   1077 
   1078 File: cpp.info,  Node: Macros,  Next: Conditionals,  Prev: Header Files,  Up: Top
   1079 
   1080 3 Macros
   1081 ********
   1082 
   1083 A "macro" is a fragment of code which has been given a name.  Whenever
   1084 the name is used, it is replaced by the contents of the macro.  There
   1085 are two kinds of macros.  They differ mostly in what they look like
   1086 when they are used.  "Object-like" macros resemble data objects when
   1087 used, "function-like" macros resemble function calls.
   1088 
   1089    You may define any valid identifier as a macro, even if it is a C
   1090 keyword.  The preprocessor does not know anything about keywords.  This
   1091 can be useful if you wish to hide a keyword such as `const' from an
   1092 older compiler that does not understand it.  However, the preprocessor
   1093 operator `defined' (*note Defined::) can never be defined as a macro,
   1094 and C++'s named operators (*note C++ Named Operators::) cannot be
   1095 macros when you are compiling C++.
   1096 
   1097 * Menu:
   1098 
   1099 * Object-like Macros::
   1100 * Function-like Macros::
   1101 * Macro Arguments::
   1102 * Stringification::
   1103 * Concatenation::
   1104 * Variadic Macros::
   1105 * Predefined Macros::
   1106 * Undefining and Redefining Macros::
   1107 * Directives Within Macro Arguments::
   1108 * Macro Pitfalls::
   1109 
   1110 
   1111 File: cpp.info,  Node: Object-like Macros,  Next: Function-like Macros,  Up: Macros
   1112 
   1113 3.1 Object-like Macros
   1114 ======================
   1115 
   1116 An "object-like macro" is a simple identifier which will be replaced by
   1117 a code fragment.  It is called object-like because it looks like a data
   1118 object in code that uses it.  They are most commonly used to give
   1119 symbolic names to numeric constants.
   1120 
   1121    You create macros with the `#define' directive.  `#define' is
   1122 followed by the name of the macro and then the token sequence it should
   1123 be an abbreviation for, which is variously referred to as the macro's
   1124 "body", "expansion" or "replacement list".  For example,
   1125 
   1126      #define BUFFER_SIZE 1024
   1127 
   1128 defines a macro named `BUFFER_SIZE' as an abbreviation for the token
   1129 `1024'.  If somewhere after this `#define' directive there comes a C
   1130 statement of the form
   1131 
   1132      foo = (char *) malloc (BUFFER_SIZE);
   1133 
   1134 then the C preprocessor will recognize and "expand" the macro
   1135 `BUFFER_SIZE'.  The C compiler will see the same tokens as it would if
   1136 you had written
   1137 
   1138      foo = (char *) malloc (1024);
   1139 
   1140    By convention, macro names are written in uppercase.  Programs are
   1141 easier to read when it is possible to tell at a glance which names are
   1142 macros.
   1143 
   1144    The macro's body ends at the end of the `#define' line.  You may
   1145 continue the definition onto multiple lines, if necessary, using
   1146 backslash-newline.  When the macro is expanded, however, it will all
   1147 come out on one line.  For example,
   1148 
   1149      #define NUMBERS 1, \
   1150                      2, \
   1151                      3
   1152      int x[] = { NUMBERS };
   1153           ==> int x[] = { 1, 2, 3 };
   1154 
   1155 The most common visible consequence of this is surprising line numbers
   1156 in error messages.
   1157 
   1158    There is no restriction on what can go in a macro body provided it
   1159 decomposes into valid preprocessing tokens.  Parentheses need not
   1160 balance, and the body need not resemble valid C code.  (If it does not,
   1161 you may get error messages from the C compiler when you use the macro.)
   1162 
   1163    The C preprocessor scans your program sequentially.  Macro
   1164 definitions take effect at the place you write them.  Therefore, the
   1165 following input to the C preprocessor
   1166 
   1167      foo = X;
   1168      #define X 4
   1169      bar = X;
   1170 
   1171 produces
   1172 
   1173      foo = X;
   1174      bar = 4;
   1175 
   1176    When the preprocessor expands a macro name, the macro's expansion
   1177 replaces the macro invocation, then the expansion is examined for more
   1178 macros to expand.  For example,
   1179 
   1180      #define TABLESIZE BUFSIZE
   1181      #define BUFSIZE 1024
   1182      TABLESIZE
   1183           ==> BUFSIZE
   1184           ==> 1024
   1185 
   1186 `TABLESIZE' is expanded first to produce `BUFSIZE', then that macro is
   1187 expanded to produce the final result, `1024'.
   1188 
   1189    Notice that `BUFSIZE' was not defined when `TABLESIZE' was defined.
   1190 The `#define' for `TABLESIZE' uses exactly the expansion you
   1191 specify--in this case, `BUFSIZE'--and does not check to see whether it
   1192 too contains macro names.  Only when you _use_ `TABLESIZE' is the
   1193 result of its expansion scanned for more macro names.
   1194 
   1195    This makes a difference if you change the definition of `BUFSIZE' at
   1196 some point in the source file.  `TABLESIZE', defined as shown, will
   1197 always expand using the definition of `BUFSIZE' that is currently in
   1198 effect:
   1199 
   1200      #define BUFSIZE 1020
   1201      #define TABLESIZE BUFSIZE
   1202      #undef BUFSIZE
   1203      #define BUFSIZE 37
   1204 
   1205 Now `TABLESIZE' expands (in two stages) to `37'.
   1206 
   1207    If the expansion of a macro contains its own name, either directly or
   1208 via intermediate macros, it is not expanded again when the expansion is
   1209 examined for more macros.  This prevents infinite recursion.  *Note
   1210 Self-Referential Macros::, for the precise details.
   1211 
   1212 
   1213 File: cpp.info,  Node: Function-like Macros,  Next: Macro Arguments,  Prev: Object-like Macros,  Up: Macros
   1214 
   1215 3.2 Function-like Macros
   1216 ========================
   1217 
   1218 You can also define macros whose use looks like a function call.  These
   1219 are called "function-like macros".  To define a function-like macro,
   1220 you use the same `#define' directive, but you put a pair of parentheses
   1221 immediately after the macro name.  For example,
   1222 
   1223      #define lang_init()  c_init()
   1224      lang_init()
   1225           ==> c_init()
   1226 
   1227    A function-like macro is only expanded if its name appears with a
   1228 pair of parentheses after it.  If you write just the name, it is left
   1229 alone.  This can be useful when you have a function and a macro of the
   1230 same name, and you wish to use the function sometimes.
   1231 
   1232      extern void foo(void);
   1233      #define foo() /* optimized inline version */
   1234      ...
   1235        foo();
   1236        funcptr = foo;
   1237 
   1238    Here the call to `foo()' will use the macro, but the function
   1239 pointer will get the address of the real function.  If the macro were to
   1240 be expanded, it would cause a syntax error.
   1241 
   1242    If you put spaces between the macro name and the parentheses in the
   1243 macro definition, that does not define a function-like macro, it defines
   1244 an object-like macro whose expansion happens to begin with a pair of
   1245 parentheses.
   1246 
   1247      #define lang_init ()    c_init()
   1248      lang_init()
   1249           ==> () c_init()()
   1250 
   1251    The first two pairs of parentheses in this expansion come from the
   1252 macro.  The third is the pair that was originally after the macro
   1253 invocation.  Since `lang_init' is an object-like macro, it does not
   1254 consume those parentheses.
   1255 
   1256 
   1257 File: cpp.info,  Node: Macro Arguments,  Next: Stringification,  Prev: Function-like Macros,  Up: Macros
   1258 
   1259 3.3 Macro Arguments
   1260 ===================
   1261 
   1262 Function-like macros can take "arguments", just like true functions.
   1263 To define a macro that uses arguments, you insert "parameters" between
   1264 the pair of parentheses in the macro definition that make the macro
   1265 function-like.  The parameters must be valid C identifiers, separated
   1266 by commas and optionally whitespace.
   1267 
   1268    To invoke a macro that takes arguments, you write the name of the
   1269 macro followed by a list of "actual arguments" in parentheses, separated
   1270 by commas.  The invocation of the macro need not be restricted to a
   1271 single logical line--it can cross as many lines in the source file as
   1272 you wish.  The number of arguments you give must match the number of
   1273 parameters in the macro definition.  When the macro is expanded, each
   1274 use of a parameter in its body is replaced by the tokens of the
   1275 corresponding argument.  (You need not use all of the parameters in the
   1276 macro body.)
   1277 
   1278    As an example, here is a macro that computes the minimum of two
   1279 numeric values, as it is defined in many C programs, and some uses.
   1280 
   1281      #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
   1282        x = min(a, b);          ==>  x = ((a) < (b) ? (a) : (b));
   1283        y = min(1, 2);          ==>  y = ((1) < (2) ? (1) : (2));
   1284        z = min(a + 28, *p);    ==>  z = ((a + 28) < (*p) ? (a + 28) : (*p));
   1285 
   1286 (In this small example you can already see several of the dangers of
   1287 macro arguments.  *Note Macro Pitfalls::, for detailed explanations.)
   1288 
   1289    Leading and trailing whitespace in each argument is dropped, and all
   1290 whitespace between the tokens of an argument is reduced to a single
   1291 space.  Parentheses within each argument must balance; a comma within
   1292 such parentheses does not end the argument.  However, there is no
   1293 requirement for square brackets or braces to balance, and they do not
   1294 prevent a comma from separating arguments.  Thus,
   1295 
   1296      macro (array[x = y, x + 1])
   1297 
   1298 passes two arguments to `macro': `array[x = y' and `x + 1]'.  If you
   1299 want to supply `array[x = y, x + 1]' as an argument, you can write it
   1300 as `array[(x = y, x + 1)]', which is equivalent C code.
   1301 
   1302    All arguments to a macro are completely macro-expanded before they
   1303 are substituted into the macro body.  After substitution, the complete
   1304 text is scanned again for macros to expand, including the arguments.
   1305 This rule may seem strange, but it is carefully designed so you need
   1306 not worry about whether any function call is actually a macro
   1307 invocation.  You can run into trouble if you try to be too clever,
   1308 though.  *Note Argument Prescan::, for detailed discussion.
   1309 
   1310    For example, `min (min (a, b), c)' is first expanded to
   1311 
   1312        min (((a) < (b) ? (a) : (b)), (c))
   1313 
   1314 and then to
   1315 
   1316      ((((a) < (b) ? (a) : (b))) < (c)
   1317       ? (((a) < (b) ? (a) : (b)))
   1318       : (c))
   1319 
   1320 (Line breaks shown here for clarity would not actually be generated.)
   1321 
   1322    You can leave macro arguments empty; this is not an error to the
   1323 preprocessor (but many macros will then expand to invalid code).  You
   1324 cannot leave out arguments entirely; if a macro takes two arguments,
   1325 there must be exactly one comma at the top level of its argument list.
   1326 Here are some silly examples using `min':
   1327 
   1328      min(, b)        ==> ((   ) < (b) ? (   ) : (b))
   1329      min(a, )        ==> ((a  ) < ( ) ? (a  ) : ( ))
   1330      min(,)          ==> ((   ) < ( ) ? (   ) : ( ))
   1331      min((,),)       ==> (((,)) < ( ) ? ((,)) : ( ))
   1332 
   1333      min()      error--> macro "min" requires 2 arguments, but only 1 given
   1334      min(,,)    error--> macro "min" passed 3 arguments, but takes just 2
   1335 
   1336    Whitespace is not a preprocessing token, so if a macro `foo' takes
   1337 one argument, `foo ()' and `foo ( )' both supply it an empty argument.
   1338 Previous GNU preprocessor implementations and documentation were
   1339 incorrect on this point, insisting that a function-like macro that
   1340 takes a single argument be passed a space if an empty argument was
   1341 required.
   1342 
   1343    Macro parameters appearing inside string literals are not replaced by
   1344 their corresponding actual arguments.
   1345 
   1346      #define foo(x) x, "x"
   1347      foo(bar)        ==> bar, "x"
   1348 
   1349 
   1350 File: cpp.info,  Node: Stringification,  Next: Concatenation,  Prev: Macro Arguments,  Up: Macros
   1351 
   1352 3.4 Stringification
   1353 ===================
   1354 
   1355 Sometimes you may want to convert a macro argument into a string
   1356 constant.  Parameters are not replaced inside string constants, but you
   1357 can use the `#' preprocessing operator instead.  When a macro parameter
   1358 is used with a leading `#', the preprocessor replaces it with the
   1359 literal text of the actual argument, converted to a string constant.
   1360 Unlike normal parameter replacement, the argument is not macro-expanded
   1361 first.  This is called "stringification".
   1362 
   1363    There is no way to combine an argument with surrounding text and
   1364 stringify it all together.  Instead, you can write a series of adjacent
   1365 string constants and stringified arguments.  The preprocessor will
   1366 replace the stringified arguments with string constants.  The C
   1367 compiler will then combine all the adjacent string constants into one
   1368 long string.
   1369 
   1370    Here is an example of a macro definition that uses stringification:
   1371 
   1372      #define WARN_IF(EXP) \
   1373      do { if (EXP) \
   1374              fprintf (stderr, "Warning: " #EXP "\n"); } \
   1375      while (0)
   1376      WARN_IF (x == 0);
   1377           ==> do { if (x == 0)
   1378                 fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0);
   1379 
   1380 The argument for `EXP' is substituted once, as-is, into the `if'
   1381 statement, and once, stringified, into the argument to `fprintf'.  If
   1382 `x' were a macro, it would be expanded in the `if' statement, but not
   1383 in the string.
   1384 
   1385    The `do' and `while (0)' are a kludge to make it possible to write
   1386 `WARN_IF (ARG);', which the resemblance of `WARN_IF' to a function
   1387 would make C programmers want to do; see *note Swallowing the
   1388 Semicolon::.
   1389 
   1390    Stringification in C involves more than putting double-quote
   1391 characters around the fragment.  The preprocessor backslash-escapes the
   1392 quotes surrounding embedded string constants, and all backslashes
   1393 within string and character constants, in order to get a valid C string
   1394 constant with the proper contents.  Thus, stringifying `p = "foo\n";'
   1395 results in "p = \"foo\\n\";".  However, backslashes that are not inside
   1396 string or character constants are not duplicated: `\n' by itself
   1397 stringifies to "\n".
   1398 
   1399    All leading and trailing whitespace in text being stringified is
   1400 ignored.  Any sequence of whitespace in the middle of the text is
   1401 converted to a single space in the stringified result.  Comments are
   1402 replaced by whitespace long before stringification happens, so they
   1403 never appear in stringified text.
   1404 
   1405    There is no way to convert a macro argument into a character
   1406 constant.
   1407 
   1408    If you want to stringify the result of expansion of a macro argument,
   1409 you have to use two levels of macros.
   1410 
   1411      #define xstr(s) str(s)
   1412      #define str(s) #s
   1413      #define foo 4
   1414      str (foo)
   1415           ==> "foo"
   1416      xstr (foo)
   1417           ==> xstr (4)
   1418           ==> str (4)
   1419           ==> "4"
   1420 
   1421    `s' is stringified when it is used in `str', so it is not
   1422 macro-expanded first.  But `s' is an ordinary argument to `xstr', so it
   1423 is completely macro-expanded before `xstr' itself is expanded (*note
   1424 Argument Prescan::).  Therefore, by the time `str' gets to its
   1425 argument, it has already been macro-expanded.
   1426 
   1427 
   1428 File: cpp.info,  Node: Concatenation,  Next: Variadic Macros,  Prev: Stringification,  Up: Macros
   1429 
   1430 3.5 Concatenation
   1431 =================
   1432 
   1433 It is often useful to merge two tokens into one while expanding macros.
   1434 This is called "token pasting" or "token concatenation".  The `##'
   1435 preprocessing operator performs token pasting.  When a macro is
   1436 expanded, the two tokens on either side of each `##' operator are
   1437 combined into a single token, which then replaces the `##' and the two
   1438 original tokens in the macro expansion.  Usually both will be
   1439 identifiers, or one will be an identifier and the other a preprocessing
   1440 number.  When pasted, they make a longer identifier.  This isn't the
   1441 only valid case.  It is also possible to concatenate two numbers (or a
   1442 number and a name, such as `1.5' and `e3') into a number.  Also,
   1443 multi-character operators such as `+=' can be formed by token pasting.
   1444 
   1445    However, two tokens that don't together form a valid token cannot be
   1446 pasted together.  For example, you cannot concatenate `x' with `+' in
   1447 either order.  If you try, the preprocessor issues a warning and emits
   1448 the two tokens.  Whether it puts white space between the tokens is
   1449 undefined.  It is common to find unnecessary uses of `##' in complex
   1450 macros.  If you get this warning, it is likely that you can simply
   1451 remove the `##'.
   1452 
   1453    Both the tokens combined by `##' could come from the macro body, but
   1454 you could just as well write them as one token in the first place.
   1455 Token pasting is most useful when one or both of the tokens comes from a
   1456 macro argument.  If either of the tokens next to an `##' is a parameter
   1457 name, it is replaced by its actual argument before `##' executes.  As
   1458 with stringification, the actual argument is not macro-expanded first.
   1459 If the argument is empty, that `##' has no effect.
   1460 
   1461    Keep in mind that the C preprocessor converts comments to whitespace
   1462 before macros are even considered.  Therefore, you cannot create a
   1463 comment by concatenating `/' and `*'.  You can put as much whitespace
   1464 between `##' and its operands as you like, including comments, and you
   1465 can put comments in arguments that will be concatenated.  However, it
   1466 is an error if `##' appears at either end of a macro body.
   1467 
   1468    Consider a C program that interprets named commands.  There probably
   1469 needs to be a table of commands, perhaps an array of structures declared
   1470 as follows:
   1471 
   1472      struct command
   1473      {
   1474        char *name;
   1475        void (*function) (void);
   1476      };
   1477 
   1478      struct command commands[] =
   1479      {
   1480        { "quit", quit_command },
   1481        { "help", help_command },
   1482        ...
   1483      };
   1484 
   1485    It would be cleaner not to have to give each command name twice,
   1486 once in the string constant and once in the function name.  A macro
   1487 which takes the name of a command as an argument can make this
   1488 unnecessary.  The string constant can be created with stringification,
   1489 and the function name by concatenating the argument with `_command'.
   1490 Here is how it is done:
   1491 
   1492      #define COMMAND(NAME)  { #NAME, NAME ## _command }
   1493 
   1494      struct command commands[] =
   1495      {
   1496        COMMAND (quit),
   1497        COMMAND (help),
   1498        ...
   1499      };
   1500 
   1501 
   1502 File: cpp.info,  Node: Variadic Macros,  Next: Predefined Macros,  Prev: Concatenation,  Up: Macros
   1503 
   1504 3.6 Variadic Macros
   1505 ===================
   1506 
   1507 A macro can be declared to accept a variable number of arguments much as
   1508 a function can.  The syntax for defining the macro is similar to that of
   1509 a function.  Here is an example:
   1510 
   1511      #define eprintf(...) fprintf (stderr, __VA_ARGS__)
   1512 
   1513    This kind of macro is called "variadic".  When the macro is invoked,
   1514 all the tokens in its argument list after the last named argument (this
   1515 macro has none), including any commas, become the "variable argument".
   1516 This sequence of tokens replaces the identifier `__VA_ARGS__' in the
   1517 macro body wherever it appears.  Thus, we have this expansion:
   1518 
   1519      eprintf ("%s:%d: ", input_file, lineno)
   1520           ==>  fprintf (stderr, "%s:%d: ", input_file, lineno)
   1521 
   1522    The variable argument is completely macro-expanded before it is
   1523 inserted into the macro expansion, just like an ordinary argument.  You
   1524 may use the `#' and `##' operators to stringify the variable argument
   1525 or to paste its leading or trailing token with another token.  (But see
   1526 below for an important special case for `##'.)
   1527 
   1528    If your macro is complicated, you may want a more descriptive name
   1529 for the variable argument than `__VA_ARGS__'.  CPP permits this, as an
   1530 extension.  You may write an argument name immediately before the
   1531 `...'; that name is used for the variable argument.  The `eprintf'
   1532 macro above could be written
   1533 
   1534      #define eprintf(args...) fprintf (stderr, args)
   1535 
   1536 using this extension.  You cannot use `__VA_ARGS__' and this extension
   1537 in the same macro.
   1538 
   1539    You can have named arguments as well as variable arguments in a
   1540 variadic macro.  We could define `eprintf' like this, instead:
   1541 
   1542      #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__)
   1543 
   1544 This formulation looks more descriptive, but unfortunately it is less
   1545 flexible: you must now supply at least one argument after the format
   1546 string.  In standard C, you cannot omit the comma separating the named
   1547 argument from the variable arguments.  Furthermore, if you leave the
   1548 variable argument empty, you will get a syntax error, because there
   1549 will be an extra comma after the format string.
   1550 
   1551      eprintf("success!\n", );
   1552           ==> fprintf(stderr, "success!\n", );
   1553 
   1554    GNU CPP has a pair of extensions which deal with this problem.
   1555 First, you are allowed to leave the variable argument out entirely:
   1556 
   1557      eprintf ("success!\n")
   1558           ==> fprintf(stderr, "success!\n", );
   1559 
   1560 Second, the `##' token paste operator has a special meaning when placed
   1561 between a comma and a variable argument.  If you write
   1562 
   1563      #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)
   1564 
   1565 and the variable argument is left out when the `eprintf' macro is used,
   1566 then the comma before the `##' will be deleted.  This does _not_ happen
   1567 if you pass an empty argument, nor does it happen if the token
   1568 preceding `##' is anything other than a comma.
   1569 
   1570      eprintf ("success!\n")
   1571           ==> fprintf(stderr, "success!\n");
   1572 
   1573 The above explanation is ambiguous about the case where the only macro
   1574 parameter is a variable arguments parameter, as it is meaningless to
   1575 try to distinguish whether no argument at all is an empty argument or a
   1576 missing argument.  In this case the C99 standard is clear that the
   1577 comma must remain, however the existing GCC extension used to swallow
   1578 the comma.  So CPP retains the comma when conforming to a specific C
   1579 standard, and drops it otherwise.
   1580 
   1581    C99 mandates that the only place the identifier `__VA_ARGS__' can
   1582 appear is in the replacement list of a variadic macro.  It may not be
   1583 used as a macro name, macro argument name, or within a different type
   1584 of macro.  It may also be forbidden in open text; the standard is
   1585 ambiguous.  We recommend you avoid using it except for its defined
   1586 purpose.
   1587 
   1588    Variadic macros are a new feature in C99.  GNU CPP has supported them
   1589 for a long time, but only with a named variable argument (`args...',
   1590 not `...' and `__VA_ARGS__').  If you are concerned with portability to
   1591 previous versions of GCC, you should use only named variable arguments.
   1592 On the other hand, if you are concerned with portability to other
   1593 conforming implementations of C99, you should use only `__VA_ARGS__'.
   1594 
   1595    Previous versions of CPP implemented the comma-deletion extension
   1596 much more generally.  We have restricted it in this release to minimize
   1597 the differences from C99.  To get the same effect with both this and
   1598 previous versions of GCC, the token preceding the special `##' must be
   1599 a comma, and there must be white space between that comma and whatever
   1600 comes immediately before it:
   1601 
   1602      #define eprintf(format, args...) fprintf (stderr, format , ##args)
   1603 
   1604 *Note Differences from previous versions::, for the gory details.
   1605 
   1606 
   1607 File: cpp.info,  Node: Predefined Macros,  Next: Undefining and Redefining Macros,  Prev: Variadic Macros,  Up: Macros
   1608 
   1609 3.7 Predefined Macros
   1610 =====================
   1611 
   1612 Several object-like macros are predefined; you use them without
   1613 supplying their definitions.  They fall into three classes: standard,
   1614 common, and system-specific.
   1615 
   1616    In C++, there is a fourth category, the named operators.  They act
   1617 like predefined macros, but you cannot undefine them.
   1618 
   1619 * Menu:
   1620 
   1621 * Standard Predefined Macros::
   1622 * Common Predefined Macros::
   1623 * System-specific Predefined Macros::
   1624 * C++ Named Operators::
   1625 
   1626 
   1627 File: cpp.info,  Node: Standard Predefined Macros,  Next: Common Predefined Macros,  Up: Predefined Macros
   1628 
   1629 3.7.1 Standard Predefined Macros
   1630 --------------------------------
   1631 
   1632 The standard predefined macros are specified by the relevant language
   1633 standards, so they are available with all compilers that implement
   1634 those standards.  Older compilers may not provide all of them.  Their
   1635 names all start with double underscores.
   1636 
   1637 `__FILE__'
   1638      This macro expands to the name of the current input file, in the
   1639      form of a C string constant.  This is the path by which the
   1640      preprocessor opened the file, not the short name specified in
   1641      `#include' or as the input file name argument.  For example,
   1642      `"/usr/local/include/myheader.h"' is a possible expansion of this
   1643      macro.
   1644 
   1645 `__LINE__'
   1646      This macro expands to the current input line number, in the form
   1647      of a decimal integer constant.  While we call it a predefined
   1648      macro, it's a pretty strange macro, since its "definition" changes
   1649      with each new line of source code.
   1650 
   1651    `__FILE__' and `__LINE__' are useful in generating an error message
   1652 to report an inconsistency detected by the program; the message can
   1653 state the source line at which the inconsistency was detected.  For
   1654 example,
   1655 
   1656      fprintf (stderr, "Internal error: "
   1657                       "negative string length "
   1658                       "%d at %s, line %d.",
   1659               length, __FILE__, __LINE__);
   1660 
   1661    An `#include' directive changes the expansions of `__FILE__' and
   1662 `__LINE__' to correspond to the included file.  At the end of that
   1663 file, when processing resumes on the input file that contained the
   1664 `#include' directive, the expansions of `__FILE__' and `__LINE__'
   1665 revert to the values they had before the `#include' (but `__LINE__' is
   1666 then incremented by one as processing moves to the line after the
   1667 `#include').
   1668 
   1669    A `#line' directive changes `__LINE__', and may change `__FILE__' as
   1670 well.  *Note Line Control::.
   1671 
   1672    C99 introduces `__func__', and GCC has provided `__FUNCTION__' for a
   1673 long time.  Both of these are strings containing the name of the
   1674 current function (there are slight semantic differences; see the GCC
   1675 manual).  Neither of them is a macro; the preprocessor does not know the
   1676 name of the current function.  They tend to be useful in conjunction
   1677 with `__FILE__' and `__LINE__', though.
   1678 
   1679 `__DATE__'
   1680      This macro expands to a string constant that describes the date on
   1681      which the preprocessor is being run.  The string constant contains
   1682      eleven characters and looks like `"Feb 12 1996"'.  If the day of
   1683      the month is less than 10, it is padded with a space on the left.
   1684 
   1685      If GCC cannot determine the current date, it will emit a warning
   1686      message (once per compilation) and `__DATE__' will expand to
   1687      `"??? ?? ????"'.
   1688 
   1689 `__TIME__'
   1690      This macro expands to a string constant that describes the time at
   1691      which the preprocessor is being run.  The string constant contains
   1692      eight characters and looks like `"23:59:01"'.
   1693 
   1694      If GCC cannot determine the current time, it will emit a warning
   1695      message (once per compilation) and `__TIME__' will expand to
   1696      `"??:??:??"'.
   1697 
   1698 `__STDC__'
   1699      In normal operation, this macro expands to the constant 1, to
   1700      signify that this compiler conforms to ISO Standard C.  If GNU CPP
   1701      is used with a compiler other than GCC, this is not necessarily
   1702      true; however, the preprocessor always conforms to the standard
   1703      unless the `-traditional-cpp' option is used.
   1704 
   1705      This macro is not defined if the `-traditional-cpp' option is used.
   1706 
   1707      On some hosts, the system compiler uses a different convention,
   1708      where `__STDC__' is normally 0, but is 1 if the user specifies
   1709      strict conformance to the C Standard.  CPP follows the host
   1710      convention when processing system header files, but when
   1711      processing user files `__STDC__' is always 1.  This has been
   1712      reported to cause problems; for instance, some versions of Solaris
   1713      provide X Windows headers that expect `__STDC__' to be either
   1714      undefined or 1.  *Note Invocation::.
   1715 
   1716 `__STDC_VERSION__'
   1717      This macro expands to the C Standard's version number, a long
   1718      integer constant of the form `YYYYMML' where YYYY and MM are the
   1719      year and month of the Standard version.  This signifies which
   1720      version of the C Standard the compiler conforms to.  Like
   1721      `__STDC__', this is not necessarily accurate for the entire
   1722      implementation, unless GNU CPP is being used with GCC.
   1723 
   1724      The value `199409L' signifies the 1989 C standard as amended in
   1725      1994, which is the current default; the value `199901L' signifies
   1726      the 1999 revision of the C standard.  Support for the 1999
   1727      revision is not yet complete.
   1728 
   1729      This macro is not defined if the `-traditional-cpp' option is
   1730      used, nor when compiling C++ or Objective-C.
   1731 
   1732 `__STDC_HOSTED__'
   1733      This macro is defined, with value 1, if the compiler's target is a
   1734      "hosted environment".  A hosted environment has the complete
   1735      facilities of the standard C library available.
   1736 
   1737 `__cplusplus'
   1738      This macro is defined when the C++ compiler is in use.  You can use
   1739      `__cplusplus' to test whether a header is compiled by a C compiler
   1740      or a C++ compiler.  This macro is similar to `__STDC_VERSION__', in
   1741      that it expands to a version number.  A fully conforming
   1742      implementation of the 1998 C++ standard will define this macro to
   1743      `199711L'.  The GNU C++ compiler is not yet fully conforming, so
   1744      it uses `1' instead.  It is hoped to complete the implementation
   1745      of standard C++ in the near future.
   1746 
   1747 `__OBJC__'
   1748      This macro is defined, with value 1, when the Objective-C compiler
   1749      is in use.  You can use `__OBJC__' to test whether a header is
   1750      compiled by a C compiler or an Objective-C compiler.
   1751 
   1752 `__ASSEMBLER__'
   1753      This macro is defined with value 1 when preprocessing assembly
   1754      language.
   1755 
   1756 
   1757 
   1758 File: cpp.info,  Node: Common Predefined Macros,  Next: System-specific Predefined Macros,  Prev: Standard Predefined Macros,  Up: Predefined Macros
   1759 
   1760 3.7.2 Common Predefined Macros
   1761 ------------------------------
   1762 
   1763 The common predefined macros are GNU C extensions.  They are available
   1764 with the same meanings regardless of the machine or operating system on
   1765 which you are using GNU C or GNU Fortran.  Their names all start with
   1766 double underscores.
   1767 
   1768 `__COUNTER__'
   1769      This macro expands to sequential integral values starting from 0.
   1770      In conjunction with the `##' operator, this provides a convenient
   1771      means to generate unique identifiers.  Care must be taken to
   1772      ensure that `__COUNTER__' is not expanded prior to inclusion of
   1773      precompiled headers which use it.  Otherwise, the precompiled
   1774      headers will not be used.
   1775 
   1776 `__GFORTRAN__'
   1777      The GNU Fortran compiler defines this.
   1778 
   1779 `__GNUC__'
   1780 `__GNUC_MINOR__'
   1781 `__GNUC_PATCHLEVEL__'
   1782      These macros are defined by all GNU compilers that use the C
   1783      preprocessor: C, C++, Objective-C and Fortran.  Their values are
   1784      the major version, minor version, and patch level of the compiler,
   1785      as integer constants.  For example, GCC 3.2.1 will define
   1786      `__GNUC__' to 3, `__GNUC_MINOR__' to 2, and `__GNUC_PATCHLEVEL__'
   1787      to 1.  These macros are also defined if you invoke the
   1788      preprocessor directly.
   1789 
   1790      `__GNUC_PATCHLEVEL__' is new to GCC 3.0; it is also present in the
   1791      widely-used development snapshots leading up to 3.0 (which identify
   1792      themselves as GCC 2.96 or 2.97, depending on which snapshot you
   1793      have).
   1794 
   1795      If all you need to know is whether or not your program is being
   1796      compiled by GCC, or a non-GCC compiler that claims to accept the
   1797      GNU C dialects, you can simply test `__GNUC__'.  If you need to
   1798      write code which depends on a specific version, you must be more
   1799      careful.  Each time the minor version is increased, the patch
   1800      level is reset to zero; each time the major version is increased
   1801      (which happens rarely), the minor version and patch level are
   1802      reset.  If you wish to use the predefined macros directly in the
   1803      conditional, you will need to write it like this:
   1804 
   1805           /* Test for GCC > 3.2.0 */
   1806           #if __GNUC__ > 3 || \
   1807               (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
   1808                                  (__GNUC_MINOR__ == 2 && \
   1809                                   __GNUC_PATCHLEVEL__ > 0))
   1810 
   1811      Another approach is to use the predefined macros to calculate a
   1812      single number, then compare that against a threshold:
   1813 
   1814           #define GCC_VERSION (__GNUC__ * 10000 \
   1815                                + __GNUC_MINOR__ * 100 \
   1816                                + __GNUC_PATCHLEVEL__)
   1817           ...
   1818           /* Test for GCC > 3.2.0 */
   1819           #if GCC_VERSION > 30200
   1820 
   1821      Many people find this form easier to understand.
   1822 
   1823 `__GNUG__'
   1824      The GNU C++ compiler defines this.  Testing it is equivalent to
   1825      testing `(__GNUC__ && __cplusplus)'.
   1826 
   1827 `__STRICT_ANSI__'
   1828      GCC defines this macro if and only if the `-ansi' switch, or a
   1829      `-std' switch specifying strict conformance to some version of ISO
   1830      C, was specified when GCC was invoked.  It is defined to `1'.
   1831      This macro exists primarily to direct GNU libc's header files to
   1832      restrict their definitions to the minimal set found in the 1989 C
   1833      standard.
   1834 
   1835 `__BASE_FILE__'
   1836      This macro expands to the name of the main input file, in the form
   1837      of a C string constant.  This is the source file that was specified
   1838      on the command line of the preprocessor or C compiler.
   1839 
   1840 `__INCLUDE_LEVEL__'
   1841      This macro expands to a decimal integer constant that represents
   1842      the depth of nesting in include files.  The value of this macro is
   1843      incremented on every `#include' directive and decremented at the
   1844      end of every included file.  It starts out at 0, its value within
   1845      the base file specified on the command line.
   1846 
   1847 `__ELF__'
   1848      This macro is defined if the target uses the ELF object format.
   1849 
   1850 `__VERSION__'
   1851      This macro expands to a string constant which describes the
   1852      version of the compiler in use.  You should not rely on its
   1853      contents having any particular form, but it can be counted on to
   1854      contain at least the release number.
   1855 
   1856 `__OPTIMIZE__'
   1857 `__OPTIMIZE_SIZE__'
   1858 `__NO_INLINE__'
   1859      These macros describe the compilation mode.  `__OPTIMIZE__' is
   1860      defined in all optimizing compilations.  `__OPTIMIZE_SIZE__' is
   1861      defined if the compiler is optimizing for size, not speed.
   1862      `__NO_INLINE__' is defined if no functions will be inlined into
   1863      their callers (when not optimizing, or when inlining has been
   1864      specifically disabled by `-fno-inline').
   1865 
   1866      These macros cause certain GNU header files to provide optimized
   1867      definitions, using macros or inline functions, of system library
   1868      functions.  You should not use these macros in any way unless you
   1869      make sure that programs will execute with the same effect whether
   1870      or not they are defined.  If they are defined, their value is 1.
   1871 
   1872 `__GNUC_GNU_INLINE__'
   1873      GCC defines this macro if functions declared `inline' will be
   1874      handled in GCC's traditional gnu90 mode.  Object files will contain
   1875      externally visible definitions of all functions declared `inline'
   1876      without `extern' or `static'.  They will not contain any
   1877      definitions of any functions declared `extern inline'.
   1878 
   1879 `__GNUC_STDC_INLINE__'
   1880      GCC defines this macro if functions declared `inline' will be
   1881      handled according to the ISO C99 standard.  Object files will
   1882      contain externally visible definitions of all functions declared
   1883      `extern inline'.  They will not contain definitions of any
   1884      functions declared `inline' without `extern'.
   1885 
   1886      If this macro is defined, GCC supports the `gnu_inline' function
   1887      attribute as a way to always get the gnu90 behavior.  Support for
   1888      this and `__GNUC_GNU_INLINE__' was added in GCC 4.1.3.  If neither
   1889      macro is defined, an older version of GCC is being used: `inline'
   1890      functions will be compiled in gnu90 mode, and the `gnu_inline'
   1891      function attribute will not be recognized.
   1892 
   1893 `__CHAR_UNSIGNED__'
   1894      GCC defines this macro if and only if the data type `char' is
   1895      unsigned on the target machine.  It exists to cause the standard
   1896      header file `limits.h' to work correctly.  You should not use this
   1897      macro yourself; instead, refer to the standard macros defined in
   1898      `limits.h'.
   1899 
   1900 `__WCHAR_UNSIGNED__'
   1901      Like `__CHAR_UNSIGNED__', this macro is defined if and only if the
   1902      data type `wchar_t' is unsigned and the front-end is in C++ mode.
   1903 
   1904 `__REGISTER_PREFIX__'
   1905      This macro expands to a single token (not a string constant) which
   1906      is the prefix applied to CPU register names in assembly language
   1907      for this target.  You can use it to write assembly that is usable
   1908      in multiple environments.  For example, in the `m68k-aout'
   1909      environment it expands to nothing, but in the `m68k-coff'
   1910      environment it expands to a single `%'.
   1911 
   1912 `__USER_LABEL_PREFIX__'
   1913      This macro expands to a single token which is the prefix applied to
   1914      user labels (symbols visible to C code) in assembly.  For example,
   1915      in the `m68k-aout' environment it expands to an `_', but in the
   1916      `m68k-coff' environment it expands to nothing.
   1917 
   1918      This macro will have the correct definition even if
   1919      `-f(no-)underscores' is in use, but it will not be correct if
   1920      target-specific options that adjust this prefix are used (e.g. the
   1921      OSF/rose `-mno-underscores' option).
   1922 
   1923 `__SIZE_TYPE__'
   1924 `__PTRDIFF_TYPE__'
   1925 `__WCHAR_TYPE__'
   1926 `__WINT_TYPE__'
   1927 `__INTMAX_TYPE__'
   1928 `__UINTMAX_TYPE__'
   1929 `__SIG_ATOMIC_TYPE__'
   1930 `__INT8_TYPE__'
   1931 `__INT16_TYPE__'
   1932 `__INT32_TYPE__'
   1933 `__INT64_TYPE__'
   1934 `__UINT8_TYPE__'
   1935 `__UINT16_TYPE__'
   1936 `__UINT32_TYPE__'
   1937 `__UINT64_TYPE__'
   1938 `__INT_LEAST8_TYPE__'
   1939 `__INT_LEAST16_TYPE__'
   1940 `__INT_LEAST32_TYPE__'
   1941 `__INT_LEAST64_TYPE__'
   1942 `__UINT_LEAST8_TYPE__'
   1943 `__UINT_LEAST16_TYPE__'
   1944 `__UINT_LEAST32_TYPE__'
   1945 `__UINT_LEAST64_TYPE__'
   1946 `__INT_FAST8_TYPE__'
   1947 `__INT_FAST16_TYPE__'
   1948 `__INT_FAST32_TYPE__'
   1949 `__INT_FAST64_TYPE__'
   1950 `__UINT_FAST8_TYPE__'
   1951 `__UINT_FAST16_TYPE__'
   1952 `__UINT_FAST32_TYPE__'
   1953 `__UINT_FAST64_TYPE__'
   1954 `__INTPTR_TYPE__'
   1955 `__UINTPTR_TYPE__'
   1956      These macros are defined to the correct underlying types for the
   1957      `size_t', `ptrdiff_t', `wchar_t', `wint_t', `intmax_t',
   1958      `uintmax_t', `sig_atomic_t', `int8_t', `int16_t', `int32_t',
   1959      `int64_t', `uint8_t', `uint16_t', `uint32_t', `uint64_t',
   1960      `int_least8_t', `int_least16_t', `int_least32_t', `int_least64_t',
   1961      `uint_least8_t', `uint_least16_t', `uint_least32_t',
   1962      `uint_least64_t', `int_fast8_t', `int_fast16_t', `int_fast32_t',
   1963      `int_fast64_t', `uint_fast8_t', `uint_fast16_t', `uint_fast32_t',
   1964      `uint_fast64_t', `intptr_t', and `uintptr_t' typedefs,
   1965      respectively.  They exist to make the standard header files
   1966      `stddef.h', `stdint.h', and `wchar.h' work correctly.  You should
   1967      not use these macros directly; instead, include the appropriate
   1968      headers and use the typedefs.  Some of these macros may not be
   1969      defined on particular systems if GCC does not provide a `stdint.h'
   1970      header on those systems.
   1971 
   1972 `__CHAR_BIT__'
   1973      Defined to the number of bits used in the representation of the
   1974      `char' data type.  It exists to make the standard header given
   1975      numerical limits work correctly.  You should not use this macro
   1976      directly; instead, include the appropriate headers.
   1977 
   1978 `__SCHAR_MAX__'
   1979 `__WCHAR_MAX__'
   1980 `__SHRT_MAX__'
   1981 `__INT_MAX__'
   1982 `__LONG_MAX__'
   1983 `__LONG_LONG_MAX__'
   1984 `__WINT_MAX__'
   1985 `__SIZE_MAX__'
   1986 `__PTRDIFF_MAX__'
   1987 `__INTMAX_MAX__'
   1988 `__UINTMAX_MAX__'
   1989 `__SIG_ATOMIC_MAX__'
   1990 `__INT8_MAX__'
   1991 `__INT16_MAX__'
   1992 `__INT32_MAX__'
   1993 `__INT64_MAX__'
   1994 `__UINT8_MAX__'
   1995 `__UINT16_MAX__'
   1996 `__UINT32_MAX__'
   1997 `__UINT64_MAX__'
   1998 `__INT_LEAST8_MAX__'
   1999 `__INT_LEAST16_MAX__'
   2000 `__INT_LEAST32_MAX__'
   2001 `__INT_LEAST64_MAX__'
   2002 `__UINT_LEAST8_MAX__'
   2003 `__UINT_LEAST16_MAX__'
   2004 `__UINT_LEAST32_MAX__'
   2005 `__UINT_LEAST64_MAX__'
   2006 `__INT_FAST8_MAX__'
   2007 `__INT_FAST16_MAX__'
   2008 `__INT_FAST32_MAX__'
   2009 `__INT_FAST64_MAX__'
   2010 `__UINT_FAST8_MAX__'
   2011 `__UINT_FAST16_MAX__'
   2012 `__UINT_FAST32_MAX__'
   2013 `__UINT_FAST64_MAX__'
   2014 `__INTPTR_MAX__'
   2015 `__UINTPTR_MAX__'
   2016 `__WCHAR_MIN__'
   2017 `__WINT_MIN__'
   2018 `__SIG_ATOMIC_MIN__'
   2019      Defined to the maximum value of the `signed char', `wchar_t',
   2020      `signed short', `signed int', `signed long', `signed long long',
   2021      `wint_t', `size_t', `ptrdiff_t', `intmax_t', `uintmax_t',
   2022      `sig_atomic_t', `int8_t', `int16_t', `int32_t', `int64_t',
   2023      `uint8_t', `uint16_t', `uint32_t', `uint64_t', `int_least8_t',
   2024      `int_least16_t', `int_least32_t', `int_least64_t',
   2025      `uint_least8_t', `uint_least16_t', `uint_least32_t',
   2026      `uint_least64_t', `int_fast8_t', `int_fast16_t', `int_fast32_t',
   2027      `int_fast64_t', `uint_fast8_t', `uint_fast16_t', `uint_fast32_t',
   2028      `uint_fast64_t', `intptr_t', and `uintptr_t' types and to the
   2029      minimum value of the `wchar_t', `wint_t', and `sig_atomic_t' types
   2030      respectively.  They exist to make the standard header given
   2031      numerical limits work correctly.  You should not use these macros
   2032      directly; instead, include the appropriate headers.  Some of these
   2033      macros may not be defined on particular systems if GCC does not
   2034      provide a `stdint.h' header on those systems.
   2035 
   2036 `__INT8_C'
   2037 `__INT16_C'
   2038 `__INT32_C'
   2039 `__INT64_C'
   2040 `__UINT8_C'
   2041 `__UINT16_C'
   2042 `__UINT32_C'
   2043 `__UINT64_C'
   2044 `__INTMAX_C'
   2045 `__UINTMAX_C'
   2046      Defined to implementations of the standard `stdint.h' macros with
   2047      the same names without the leading `__'.  They exist the make the
   2048      implementation of that header work correctly.  You should not use
   2049      these macros directly; instead, include the appropriate headers.
   2050      Some of these macros may not be defined on particular systems if
   2051      GCC does not provide a `stdint.h' header on those systems.
   2052 
   2053 `__SIZEOF_INT__'
   2054 `__SIZEOF_LONG__'
   2055 `__SIZEOF_LONG_LONG__'
   2056 `__SIZEOF_SHORT__'
   2057 `__SIZEOF_POINTER__'
   2058 `__SIZEOF_FLOAT__'
   2059 `__SIZEOF_DOUBLE__'
   2060 `__SIZEOF_LONG_DOUBLE__'
   2061 `__SIZEOF_SIZE_T__'
   2062 `__SIZEOF_WCHAR_T__'
   2063 `__SIZEOF_WINT_T__'
   2064 `__SIZEOF_PTRDIFF_T__'
   2065      Defined to the number of bytes of the C standard data types: `int',
   2066      `long', `long long', `short', `void *', `float', `double', `long
   2067      double', `size_t', `wchar_t', `wint_t' and `ptrdiff_t'.
   2068 
   2069 `__BYTE_ORDER__'
   2070 `__ORDER_LITTLE_ENDIAN__'
   2071 `__ORDER_BIG_ENDIAN__'
   2072 `__ORDER_PDP_ENDIAN__'
   2073      `__BYTE_ORDER__' is defined to one of the values
   2074      `__ORDER_LITTLE_ENDIAN__', `__ORDER_BIG_ENDIAN__', or
   2075      `__ORDER_PDP_ENDIAN__' to reflect the layout of multi-byte and
   2076      multi-word quantities in memory.  If `__BYTE_ORDER__' is equal to
   2077      `__ORDER_LITTLE_ENDIAN__' or `__ORDER_BIG_ENDIAN__', then
   2078      multi-byte and multi-word quantities are laid out identically: the
   2079      byte (word) at the lowest address is the least significant or most
   2080      significant byte (word) of the quantity, respectively.  If
   2081      `__BYTE_ORDER__' is equal to `__ORDER_PDP_ENDIAN__', then bytes in
   2082      16-bit words are laid out in a little-endian fashion, whereas the
   2083      16-bit subwords of a 32-bit quantity are laid out in big-endian
   2084      fashion.
   2085 
   2086      You should use these macros for testing like this:
   2087 
   2088           /* Test for a little-endian machine */
   2089           #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
   2090 
   2091 `__FLOAT_WORD_ORDER__'
   2092      `__FLOAT_WORD_ORDER__' is defined to one of the values
   2093      `__ORDER_LITTLE_ENDIAN__' or `__ORDER_BIG_ENDIAN__' to reflect the
   2094      layout of the words of multi-word floating-point quantities.
   2095 
   2096 `__DEPRECATED'
   2097      This macro is defined, with value 1, when compiling a C++ source
   2098      file with warnings about deprecated constructs enabled.  These
   2099      warnings are enabled by default, but can be disabled with
   2100      `-Wno-deprecated'.
   2101 
   2102 `__EXCEPTIONS'
   2103      This macro is defined, with value 1, when compiling a C++ source
   2104      file with exceptions enabled.  If `-fno-exceptions' is used when
   2105      compiling the file, then this macro is not defined.
   2106 
   2107 `__GXX_RTTI'
   2108      This macro is defined, with value 1, when compiling a C++ source
   2109      file with runtime type identification enabled.  If `-fno-rtti' is
   2110      used when compiling the file, then this macro is not defined.
   2111 
   2112 `__USING_SJLJ_EXCEPTIONS__'
   2113      This macro is defined, with value 1, if the compiler uses the old
   2114      mechanism based on `setjmp' and `longjmp' for exception handling.
   2115 
   2116 `__GXX_EXPERIMENTAL_CXX0X__'
   2117      This macro is defined when compiling a C++ source file with the
   2118      option `-std=c++0x' or `-std=gnu++0x'. It indicates that some
   2119      features likely to be included in C++0x are available. Note that
   2120      these features are experimental, and may change or be removed in
   2121      future versions of GCC.
   2122 
   2123 `__GXX_WEAK__'
   2124      This macro is defined when compiling a C++ source file.  It has the
   2125      value 1 if the compiler will use weak symbols, COMDAT sections, or
   2126      other similar techniques to collapse symbols with "vague linkage"
   2127      that are defined in multiple translation units.  If the compiler
   2128      will not collapse such symbols, this macro is defined with value
   2129      0.  In general, user code should not need to make use of this
   2130      macro; the purpose of this macro is to ease implementation of the
   2131      C++ runtime library provided with G++.
   2132 
   2133 `__NEXT_RUNTIME__'
   2134      This macro is defined, with value 1, if (and only if) the NeXT
   2135      runtime (as in `-fnext-runtime') is in use for Objective-C.  If
   2136      the GNU runtime is used, this macro is not defined, so that you
   2137      can use this macro to determine which runtime (NeXT or GNU) is
   2138      being used.
   2139 
   2140 `__LP64__'
   2141 `_LP64'
   2142      These macros are defined, with value 1, if (and only if) the
   2143      compilation is for a target where `long int' and pointer both use
   2144      64-bits and `int' uses 32-bit.
   2145 
   2146 `__SSP__'
   2147      This macro is defined, with value 1, when `-fstack-protector' is in
   2148      use.
   2149 
   2150 `__SSP_ALL__'
   2151      This macro is defined, with value 2, when `-fstack-protector-all'
   2152      is in use.
   2153 
   2154 `__TIMESTAMP__'
   2155      This macro expands to a string constant that describes the date
   2156      and time of the last modification of the current source file. The
   2157      string constant contains abbreviated day of the week, month, day
   2158      of the month, time in hh:mm:ss form, year and looks like
   2159      `"Sun Sep 16 01:03:52 1973"'.  If the day of the month is less
   2160      than 10, it is padded with a space on the left.
   2161 
   2162      If GCC cannot determine the current date, it will emit a warning
   2163      message (once per compilation) and `__TIMESTAMP__' will expand to
   2164      `"??? ??? ?? ??:??:?? ????"'.
   2165 
   2166 `__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1'
   2167 `__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2'
   2168 `__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4'
   2169 `__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8'
   2170 `__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16'
   2171      These macros are defined when the target processor supports atomic
   2172      compare and swap operations on operands 1, 2, 4, 8 or 16 bytes in
   2173      length, respectively.
   2174 
   2175 `__GCC_HAVE_DWARF2_CFI_ASM'
   2176      This macro is defined when the compiler is emitting Dwarf2 CFI
   2177      directives to the assembler.  When this is defined, it is possible
   2178      to emit those same directives in inline assembly.
   2179 
   2180 `__FP_FAST_FMA'
   2181 `__FP_FAST_FMAF'
   2182 `__FP_FAST_FMAL'
   2183      These macros are defined with value 1 if the backend supports the
   2184      `fma', `fmaf', and `fmal' builtin functions, so that the include
   2185      file `math.h' can define the macros `FP_FAST_FMA', `FP_FAST_FMAF',
   2186      and `FP_FAST_FMAL' for compatibility with the 1999 C standard.
   2187 
   2188 
   2189 File: cpp.info,  Node: System-specific Predefined Macros,  Next: C++ Named Operators,  Prev: Common Predefined Macros,  Up: Predefined Macros
   2190 
   2191 3.7.3 System-specific Predefined Macros
   2192 ---------------------------------------
   2193 
   2194 The C preprocessor normally predefines several macros that indicate what
   2195 type of system and machine is in use.  They are obviously different on
   2196 each target supported by GCC.  This manual, being for all systems and
   2197 machines, cannot tell you what their names are, but you can use `cpp
   2198 -dM' to see them all.  *Note Invocation::.  All system-specific
   2199 predefined macros expand to the constant 1, so you can test them with
   2200 either `#ifdef' or `#if'.
   2201 
   2202    The C standard requires that all system-specific macros be part of
   2203 the "reserved namespace".  All names which begin with two underscores,
   2204 or an underscore and a capital letter, are reserved for the compiler and
   2205 library to use as they wish.  However, historically system-specific
   2206 macros have had names with no special prefix; for instance, it is common
   2207 to find `unix' defined on Unix systems.  For all such macros, GCC
   2208 provides a parallel macro with two underscores added at the beginning
   2209 and the end.  If `unix' is defined, `__unix__' will be defined too.
   2210 There will never be more than two underscores; the parallel of `_mips'
   2211 is `__mips__'.
   2212 
   2213    When the `-ansi' option, or any `-std' option that requests strict
   2214 conformance, is given to the compiler, all the system-specific
   2215 predefined macros outside the reserved namespace are suppressed.  The
   2216 parallel macros, inside the reserved namespace, remain defined.
   2217 
   2218    We are slowly phasing out all predefined macros which are outside the
   2219 reserved namespace.  You should never use them in new programs, and we
   2220 encourage you to correct older code to use the parallel macros whenever
   2221 you find it.  We don't recommend you use the system-specific macros that
   2222 are in the reserved namespace, either.  It is better in the long run to
   2223 check specifically for features you need, using a tool such as
   2224 `autoconf'.
   2225 
   2226 
   2227 File: cpp.info,  Node: C++ Named Operators,  Prev: System-specific Predefined Macros,  Up: Predefined Macros
   2228 
   2229 3.7.4 C++ Named Operators
   2230 -------------------------
   2231 
   2232 In C++, there are eleven keywords which are simply alternate spellings
   2233 of operators normally written with punctuation.  These keywords are
   2234 treated as such even in the preprocessor.  They function as operators in
   2235 `#if', and they cannot be defined as macros or poisoned.  In C, you can
   2236 request that those keywords take their C++ meaning by including
   2237 `iso646.h'.  That header defines each one as a normal object-like macro
   2238 expanding to the appropriate punctuator.
   2239 
   2240    These are the named operators and their corresponding punctuators:
   2241 
   2242 Named Operator   Punctuator
   2243 `and'            `&&'
   2244 `and_eq'         `&='
   2245 `bitand'         `&'
   2246 `bitor'          `|'
   2247 `compl'          `~'
   2248 `not'            `!'
   2249 `not_eq'         `!='
   2250 `or'             `||'
   2251 `or_eq'          `|='
   2252 `xor'            `^'
   2253 `xor_eq'         `^='
   2254 
   2255 
   2256 File: cpp.info,  Node: Undefining and Redefining Macros,  Next: Directives Within Macro Arguments,  Prev: Predefined Macros,  Up: Macros
   2257 
   2258 3.8 Undefining and Redefining Macros
   2259 ====================================
   2260 
   2261 If a macro ceases to be useful, it may be "undefined" with the `#undef'
   2262 directive.  `#undef' takes a single argument, the name of the macro to
   2263 undefine.  You use the bare macro name, even if the macro is
   2264 function-like.  It is an error if anything appears on the line after
   2265 the macro name.  `#undef' has no effect if the name is not a macro.
   2266 
   2267      #define FOO 4
   2268      x = FOO;        ==> x = 4;
   2269      #undef FOO
   2270      x = FOO;        ==> x = FOO;
   2271 
   2272    Once a macro has been undefined, that identifier may be "redefined"
   2273 as a macro by a subsequent `#define' directive.  The new definition
   2274 need not have any resemblance to the old definition.
   2275 
   2276    However, if an identifier which is currently a macro is redefined,
   2277 then the new definition must be "effectively the same" as the old one.
   2278 Two macro definitions are effectively the same if:
   2279    * Both are the same type of macro (object- or function-like).
   2280 
   2281    * All the tokens of the replacement list are the same.
   2282 
   2283    * If there are any parameters, they are the same.
   2284 
   2285    * Whitespace appears in the same places in both.  It need not be
   2286      exactly the same amount of whitespace, though.  Remember that
   2287      comments count as whitespace.
   2288 
   2289 These definitions are effectively the same:
   2290      #define FOUR (2 + 2)
   2291      #define FOUR         (2    +    2)
   2292      #define FOUR (2 /* two */ + 2)
   2293    but these are not:
   2294      #define FOUR (2 + 2)
   2295      #define FOUR ( 2+2 )
   2296      #define FOUR (2 * 2)
   2297      #define FOUR(score,and,seven,years,ago) (2 + 2)
   2298 
   2299    If a macro is redefined with a definition that is not effectively the
   2300 same as the old one, the preprocessor issues a warning and changes the
   2301 macro to use the new definition.  If the new definition is effectively
   2302 the same, the redefinition is silently ignored.  This allows, for
   2303 instance, two different headers to define a common macro.  The
   2304 preprocessor will only complain if the definitions do not match.
   2305 
   2306 
   2307 File: cpp.info,  Node: Directives Within Macro Arguments,  Next: Macro Pitfalls,  Prev: Undefining and Redefining Macros,  Up: Macros
   2308 
   2309 3.9 Directives Within Macro Arguments
   2310 =====================================
   2311 
   2312 Occasionally it is convenient to use preprocessor directives within the
   2313 arguments of a macro.  The C and C++ standards declare that behavior in
   2314 these cases is undefined.
   2315 
   2316    Versions of CPP prior to 3.2 would reject such constructs with an
   2317 error message.  This was the only syntactic difference between normal
   2318 functions and function-like macros, so it seemed attractive to remove
   2319 this limitation, and people would often be surprised that they could
   2320 not use macros in this way.  Moreover, sometimes people would use
   2321 conditional compilation in the argument list to a normal library
   2322 function like `printf', only to find that after a library upgrade
   2323 `printf' had changed to be a function-like macro, and their code would
   2324 no longer compile.  So from version 3.2 we changed CPP to successfully
   2325 process arbitrary directives within macro arguments in exactly the same
   2326 way as it would have processed the directive were the function-like
   2327 macro invocation not present.
   2328 
   2329    If, within a macro invocation, that macro is redefined, then the new
   2330 definition takes effect in time for argument pre-expansion, but the
   2331 original definition is still used for argument replacement.  Here is a
   2332 pathological example:
   2333 
   2334      #define f(x) x x
   2335      f (1
   2336      #undef f
   2337      #define f 2
   2338      f)
   2339 
   2340 which expands to
   2341 
   2342      1 2 1 2
   2343 
   2344 with the semantics described above.
   2345 
   2346 
   2347 File: cpp.info,  Node: Macro Pitfalls,  Prev: Directives Within Macro Arguments,  Up: Macros
   2348 
   2349 3.10 Macro Pitfalls
   2350 ===================
   2351 
   2352 In this section we describe some special rules that apply to macros and
   2353 macro expansion, and point out certain cases in which the rules have
   2354 counter-intuitive consequences that you must watch out for.
   2355 
   2356 * Menu:
   2357 
   2358 * Misnesting::
   2359 * Operator Precedence Problems::
   2360 * Swallowing the Semicolon::
   2361 * Duplication of Side Effects::
   2362 * Self-Referential Macros::
   2363 * Argument Prescan::
   2364 * Newlines in Arguments::
   2365 
   2366 
   2367 File: cpp.info,  Node: Misnesting,  Next: Operator Precedence Problems,  Up: Macro Pitfalls
   2368 
   2369 3.10.1 Misnesting
   2370 -----------------
   2371 
   2372 When a macro is called with arguments, the arguments are substituted
   2373 into the macro body and the result is checked, together with the rest of
   2374 the input file, for more macro calls.  It is possible to piece together
   2375 a macro call coming partially from the macro body and partially from the
   2376 arguments.  For example,
   2377 
   2378      #define twice(x) (2*(x))
   2379      #define call_with_1(x) x(1)
   2380      call_with_1 (twice)
   2381           ==> twice(1)
   2382           ==> (2*(1))
   2383 
   2384    Macro definitions do not have to have balanced parentheses.  By
   2385 writing an unbalanced open parenthesis in a macro body, it is possible
   2386 to create a macro call that begins inside the macro body but ends
   2387 outside of it.  For example,
   2388 
   2389      #define strange(file) fprintf (file, "%s %d",
   2390      ...
   2391      strange(stderr) p, 35)
   2392           ==> fprintf (stderr, "%s %d", p, 35)
   2393 
   2394    The ability to piece together a macro call can be useful, but the
   2395 use of unbalanced open parentheses in a macro body is just confusing,
   2396 and should be avoided.
   2397 
   2398 
   2399 File: cpp.info,  Node: Operator Precedence Problems,  Next: Swallowing the Semicolon,  Prev: Misnesting,  Up: Macro Pitfalls
   2400 
   2401 3.10.2 Operator Precedence Problems
   2402 -----------------------------------
   2403 
   2404 You may have noticed that in most of the macro definition examples shown
   2405 above, each occurrence of a macro argument name had parentheses around
   2406 it.  In addition, another pair of parentheses usually surround the
   2407 entire macro definition.  Here is why it is best to write macros that
   2408 way.
   2409 
   2410    Suppose you define a macro as follows,
   2411 
   2412      #define ceil_div(x, y) (x + y - 1) / y
   2413 
   2414 whose purpose is to divide, rounding up.  (One use for this operation is
   2415 to compute how many `int' objects are needed to hold a certain number
   2416 of `char' objects.)  Then suppose it is used as follows:
   2417 
   2418      a = ceil_div (b & c, sizeof (int));
   2419           ==> a = (b & c + sizeof (int) - 1) / sizeof (int);
   2420 
   2421 This does not do what is intended.  The operator-precedence rules of C
   2422 make it equivalent to this:
   2423 
   2424      a = (b & (c + sizeof (int) - 1)) / sizeof (int);
   2425 
   2426 What we want is this:
   2427 
   2428      a = ((b & c) + sizeof (int) - 1)) / sizeof (int);
   2429 
   2430 Defining the macro as
   2431 
   2432      #define ceil_div(x, y) ((x) + (y) - 1) / (y)
   2433 
   2434 provides the desired result.
   2435 
   2436    Unintended grouping can result in another way.  Consider `sizeof
   2437 ceil_div(1, 2)'.  That has the appearance of a C expression that would
   2438 compute the size of the type of `ceil_div (1, 2)', but in fact it means
   2439 something very different.  Here is what it expands to:
   2440 
   2441      sizeof ((1) + (2) - 1) / (2)
   2442 
   2443 This would take the size of an integer and divide it by two.  The
   2444 precedence rules have put the division outside the `sizeof' when it was
   2445 intended to be inside.
   2446 
   2447    Parentheses around the entire macro definition prevent such problems.
   2448 Here, then, is the recommended way to define `ceil_div':
   2449 
   2450      #define ceil_div(x, y) (((x) + (y) - 1) / (y))
   2451 
   2452 
   2453 File: cpp.info,  Node: Swallowing the Semicolon,  Next: Duplication of Side Effects,  Prev: Operator Precedence Problems,  Up: Macro Pitfalls
   2454 
   2455 3.10.3 Swallowing the Semicolon
   2456 -------------------------------
   2457 
   2458 Often it is desirable to define a macro that expands into a compound
   2459 statement.  Consider, for example, the following macro, that advances a
   2460 pointer (the argument `p' says where to find it) across whitespace
   2461 characters:
   2462 
   2463      #define SKIP_SPACES(p, limit)  \
   2464      { char *lim = (limit);         \
   2465        while (p < lim) {            \
   2466          if (*p++ != ' ') {         \
   2467            p--; break; }}}
   2468 
   2469 Here backslash-newline is used to split the macro definition, which must
   2470 be a single logical line, so that it resembles the way such code would
   2471 be laid out if not part of a macro definition.
   2472 
   2473    A call to this macro might be `SKIP_SPACES (p, lim)'.  Strictly
   2474 speaking, the call expands to a compound statement, which is a complete
   2475 statement with no need for a semicolon to end it.  However, since it
   2476 looks like a function call, it minimizes confusion if you can use it
   2477 like a function call, writing a semicolon afterward, as in `SKIP_SPACES
   2478 (p, lim);'
   2479 
   2480    This can cause trouble before `else' statements, because the
   2481 semicolon is actually a null statement.  Suppose you write
   2482 
   2483      if (*p != 0)
   2484        SKIP_SPACES (p, lim);
   2485      else ...
   2486 
   2487 The presence of two statements--the compound statement and a null
   2488 statement--in between the `if' condition and the `else' makes invalid C
   2489 code.
   2490 
   2491    The definition of the macro `SKIP_SPACES' can be altered to solve
   2492 this problem, using a `do ... while' statement.  Here is how:
   2493 
   2494      #define SKIP_SPACES(p, limit)     \
   2495      do { char *lim = (limit);         \
   2496           while (p < lim) {            \
   2497             if (*p++ != ' ') {         \
   2498               p--; break; }}}          \
   2499      while (0)
   2500 
   2501    Now `SKIP_SPACES (p, lim);' expands into
   2502 
   2503      do {...} while (0);
   2504 
   2505 which is one statement.  The loop executes exactly once; most compilers
   2506 generate no extra code for it.
   2507 
   2508 
   2509 File: cpp.info,  Node: Duplication of Side Effects,  Next: Self-Referential Macros,  Prev: Swallowing the Semicolon,  Up: Macro Pitfalls
   2510 
   2511 3.10.4 Duplication of Side Effects
   2512 ----------------------------------
   2513 
   2514 Many C programs define a macro `min', for "minimum", like this:
   2515 
   2516      #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
   2517 
   2518    When you use this macro with an argument containing a side effect,
   2519 as shown here,
   2520 
   2521      next = min (x + y, foo (z));
   2522 
   2523 it expands as follows:
   2524 
   2525      next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
   2526 
   2527 where `x + y' has been substituted for `X' and `foo (z)' for `Y'.
   2528 
   2529    The function `foo' is used only once in the statement as it appears
   2530 in the program, but the expression `foo (z)' has been substituted twice
   2531 into the macro expansion.  As a result, `foo' might be called two times
   2532 when the statement is executed.  If it has side effects or if it takes
   2533 a long time to compute, the results might not be what you intended.  We
   2534 say that `min' is an "unsafe" macro.
   2535 
   2536    The best solution to this problem is to define `min' in a way that
   2537 computes the value of `foo (z)' only once.  The C language offers no
   2538 standard way to do this, but it can be done with GNU extensions as
   2539 follows:
   2540 
   2541      #define min(X, Y)                \
   2542      ({ typeof (X) x_ = (X);          \
   2543         typeof (Y) y_ = (Y);          \
   2544         (x_ < y_) ? x_ : y_; })
   2545 
   2546    The `({ ... })' notation produces a compound statement that acts as
   2547 an expression.  Its value is the value of its last statement.  This
   2548 permits us to define local variables and assign each argument to one.
   2549 The local variables have underscores after their names to reduce the
   2550 risk of conflict with an identifier of wider scope (it is impossible to
   2551 avoid this entirely).  Now each argument is evaluated exactly once.
   2552 
   2553    If you do not wish to use GNU C extensions, the only solution is to
   2554 be careful when _using_ the macro `min'.  For example, you can
   2555 calculate the value of `foo (z)', save it in a variable, and use that
   2556 variable in `min':
   2557 
   2558      #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
   2559      ...
   2560      {
   2561        int tem = foo (z);
   2562        next = min (x + y, tem);
   2563      }
   2564 
   2565 (where we assume that `foo' returns type `int').
   2566 
   2567 
   2568 File: cpp.info,  Node: Self-Referential Macros,  Next: Argument Prescan,  Prev: Duplication of Side Effects,  Up: Macro Pitfalls
   2569 
   2570 3.10.5 Self-Referential Macros
   2571 ------------------------------
   2572 
   2573 A "self-referential" macro is one whose name appears in its definition.
   2574 Recall that all macro definitions are rescanned for more macros to
   2575 replace.  If the self-reference were considered a use of the macro, it
   2576 would produce an infinitely large expansion.  To prevent this, the
   2577 self-reference is not considered a macro call.  It is passed into the
   2578 preprocessor output unchanged.  Consider an example:
   2579 
   2580      #define foo (4 + foo)
   2581 
   2582 where `foo' is also a variable in your program.
   2583 
   2584    Following the ordinary rules, each reference to `foo' will expand
   2585 into `(4 + foo)'; then this will be rescanned and will expand into `(4
   2586 + (4 + foo))'; and so on until the computer runs out of memory.
   2587 
   2588    The self-reference rule cuts this process short after one step, at
   2589 `(4 + foo)'.  Therefore, this macro definition has the possibly useful
   2590 effect of causing the program to add 4 to the value of `foo' wherever
   2591 `foo' is referred to.
   2592 
   2593    In most cases, it is a bad idea to take advantage of this feature.  A
   2594 person reading the program who sees that `foo' is a variable will not
   2595 expect that it is a macro as well.  The reader will come across the
   2596 identifier `foo' in the program and think its value should be that of
   2597 the variable `foo', whereas in fact the value is four greater.
   2598 
   2599    One common, useful use of self-reference is to create a macro which
   2600 expands to itself.  If you write
   2601 
   2602      #define EPERM EPERM
   2603 
   2604 then the macro `EPERM' expands to `EPERM'.  Effectively, it is left
   2605 alone by the preprocessor whenever it's used in running text.  You can
   2606 tell that it's a macro with `#ifdef'.  You might do this if you want to
   2607 define numeric constants with an `enum', but have `#ifdef' be true for
   2608 each constant.
   2609 
   2610    If a macro `x' expands to use a macro `y', and the expansion of `y'
   2611 refers to the macro `x', that is an "indirect self-reference" of `x'.
   2612 `x' is not expanded in this case either.  Thus, if we have
   2613 
   2614      #define x (4 + y)
   2615      #define y (2 * x)
   2616 
   2617 then `x' and `y' expand as follows:
   2618 
   2619      x    ==> (4 + y)
   2620           ==> (4 + (2 * x))
   2621 
   2622      y    ==> (2 * x)
   2623           ==> (2 * (4 + y))
   2624 
   2625 Each macro is expanded when it appears in the definition of the other
   2626 macro, but not when it indirectly appears in its own definition.
   2627 
   2628 
   2629 File: cpp.info,  Node: Argument Prescan,  Next: Newlines in Arguments,  Prev: Self-Referential Macros,  Up: Macro Pitfalls
   2630 
   2631 3.10.6 Argument Prescan
   2632 -----------------------
   2633 
   2634 Macro arguments are completely macro-expanded before they are
   2635 substituted into a macro body, unless they are stringified or pasted
   2636 with other tokens.  After substitution, the entire macro body, including
   2637 the substituted arguments, is scanned again for macros to be expanded.
   2638 The result is that the arguments are scanned _twice_ to expand macro
   2639 calls in them.
   2640 
   2641    Most of the time, this has no effect.  If the argument contained any
   2642 macro calls, they are expanded during the first scan.  The result
   2643 therefore contains no macro calls, so the second scan does not change
   2644 it.  If the argument were substituted as given, with no prescan, the
   2645 single remaining scan would find the same macro calls and produce the
   2646 same results.
   2647 
   2648    You might expect the double scan to change the results when a
   2649 self-referential macro is used in an argument of another macro (*note
   2650 Self-Referential Macros::): the self-referential macro would be
   2651 expanded once in the first scan, and a second time in the second scan.
   2652 However, this is not what happens.  The self-references that do not
   2653 expand in the first scan are marked so that they will not expand in the
   2654 second scan either.
   2655 
   2656    You might wonder, "Why mention the prescan, if it makes no
   2657 difference?  And why not skip it and make the preprocessor faster?"
   2658 The answer is that the prescan does make a difference in three special
   2659 cases:
   2660 
   2661    * Nested calls to a macro.
   2662 
   2663      We say that "nested" calls to a macro occur when a macro's argument
   2664      contains a call to that very macro.  For example, if `f' is a macro
   2665      that expects one argument, `f (f (1))' is a nested pair of calls to
   2666      `f'.  The desired expansion is made by expanding `f (1)' and
   2667      substituting that into the definition of `f'.  The prescan causes
   2668      the expected result to happen.  Without the prescan, `f (1)' itself
   2669      would be substituted as an argument, and the inner use of `f' would
   2670      appear during the main scan as an indirect self-reference and
   2671      would not be expanded.
   2672 
   2673    * Macros that call other macros that stringify or concatenate.
   2674 
   2675      If an argument is stringified or concatenated, the prescan does not
   2676      occur.  If you _want_ to expand a macro, then stringify or
   2677      concatenate its expansion, you can do that by causing one macro to
   2678      call another macro that does the stringification or concatenation.
   2679      For instance, if you have
   2680 
   2681           #define AFTERX(x) X_ ## x
   2682           #define XAFTERX(x) AFTERX(x)
   2683           #define TABLESIZE 1024
   2684           #define BUFSIZE TABLESIZE
   2685 
   2686      then `AFTERX(BUFSIZE)' expands to `X_BUFSIZE', and
   2687      `XAFTERX(BUFSIZE)' expands to `X_1024'.  (Not to `X_TABLESIZE'.
   2688      Prescan always does a complete expansion.)
   2689 
   2690    * Macros used in arguments, whose expansions contain unshielded
   2691      commas.
   2692 
   2693      This can cause a macro expanded on the second scan to be called
   2694      with the wrong number of arguments.  Here is an example:
   2695 
   2696           #define foo  a,b
   2697           #define bar(x) lose(x)
   2698           #define lose(x) (1 + (x))
   2699 
   2700      We would like `bar(foo)' to turn into `(1 + (foo))', which would
   2701      then turn into `(1 + (a,b))'.  Instead, `bar(foo)' expands into
   2702      `lose(a,b)', and you get an error because `lose' requires a single
   2703      argument.  In this case, the problem is easily solved by the same
   2704      parentheses that ought to be used to prevent misnesting of
   2705      arithmetic operations:
   2706 
   2707           #define foo (a,b)
   2708      or
   2709           #define bar(x) lose((x))
   2710 
   2711      The extra pair of parentheses prevents the comma in `foo''s
   2712      definition from being interpreted as an argument separator.
   2713 
   2714 
   2715 
   2716 File: cpp.info,  Node: Newlines in Arguments,  Prev: Argument Prescan,  Up: Macro Pitfalls
   2717 
   2718 3.10.7 Newlines in Arguments
   2719 ----------------------------
   2720 
   2721 The invocation of a function-like macro can extend over many logical
   2722 lines.  However, in the present implementation, the entire expansion
   2723 comes out on one line.  Thus line numbers emitted by the compiler or
   2724 debugger refer to the line the invocation started on, which might be
   2725 different to the line containing the argument causing the problem.
   2726 
   2727    Here is an example illustrating this:
   2728 
   2729      #define ignore_second_arg(a,b,c) a; c
   2730 
   2731      ignore_second_arg (foo (),
   2732                         ignored (),
   2733                         syntax error);
   2734 
   2735 The syntax error triggered by the tokens `syntax error' results in an
   2736 error message citing line three--the line of ignore_second_arg-- even
   2737 though the problematic code comes from line five.
   2738 
   2739    We consider this a bug, and intend to fix it in the near future.
   2740 
   2741 
   2742 File: cpp.info,  Node: Conditionals,  Next: Diagnostics,  Prev: Macros,  Up: Top
   2743 
   2744 4 Conditionals
   2745 **************
   2746 
   2747 A "conditional" is a directive that instructs the preprocessor to
   2748 select whether or not to include a chunk of code in the final token
   2749 stream passed to the compiler.  Preprocessor conditionals can test
   2750 arithmetic expressions, or whether a name is defined as a macro, or both
   2751 simultaneously using the special `defined' operator.
   2752 
   2753    A conditional in the C preprocessor resembles in some ways an `if'
   2754 statement in C, but it is important to understand the difference between
   2755 them.  The condition in an `if' statement is tested during the
   2756 execution of your program.  Its purpose is to allow your program to
   2757 behave differently from run to run, depending on the data it is
   2758 operating on.  The condition in a preprocessing conditional directive is
   2759 tested when your program is compiled.  Its purpose is to allow different
   2760 code to be included in the program depending on the situation at the
   2761 time of compilation.
   2762 
   2763    However, the distinction is becoming less clear.  Modern compilers
   2764 often do test `if' statements when a program is compiled, if their
   2765 conditions are known not to vary at run time, and eliminate code which
   2766 can never be executed.  If you can count on your compiler to do this,
   2767 you may find that your program is more readable if you use `if'
   2768 statements with constant conditions (perhaps determined by macros).  Of
   2769 course, you can only use this to exclude code, not type definitions or
   2770 other preprocessing directives, and you can only do it if the code
   2771 remains syntactically valid when it is not to be used.
   2772 
   2773    GCC version 3 eliminates this kind of never-executed code even when
   2774 not optimizing.  Older versions did it only when optimizing.
   2775 
   2776 * Menu:
   2777 
   2778 * Conditional Uses::
   2779 * Conditional Syntax::
   2780 * Deleted Code::
   2781 
   2782 
   2783 File: cpp.info,  Node: Conditional Uses,  Next: Conditional Syntax,  Up: Conditionals
   2784 
   2785 4.1 Conditional Uses
   2786 ====================
   2787 
   2788 There are three general reasons to use a conditional.
   2789 
   2790    * A program may need to use different code depending on the machine
   2791      or operating system it is to run on.  In some cases the code for
   2792      one operating system may be erroneous on another operating system;
   2793      for example, it might refer to data types or constants that do not
   2794      exist on the other system.  When this happens, it is not enough to
   2795      avoid executing the invalid code.  Its mere presence will cause
   2796      the compiler to reject the program.  With a preprocessing
   2797      conditional, the offending code can be effectively excised from
   2798      the program when it is not valid.
   2799 
   2800    * You may want to be able to compile the same source file into two
   2801      different programs.  One version might make frequent time-consuming
   2802      consistency checks on its intermediate data, or print the values of
   2803      those data for debugging, and the other not.
   2804 
   2805    * A conditional whose condition is always false is one way to
   2806      exclude code from the program but keep it as a sort of comment for
   2807      future reference.
   2808 
   2809    Simple programs that do not need system-specific logic or complex
   2810 debugging hooks generally will not need to use preprocessing
   2811 conditionals.
   2812 
   2813 
   2814 File: cpp.info,  Node: Conditional Syntax,  Next: Deleted Code,  Prev: Conditional Uses,  Up: Conditionals
   2815 
   2816 4.2 Conditional Syntax
   2817 ======================
   2818 
   2819 A conditional in the C preprocessor begins with a "conditional
   2820 directive": `#if', `#ifdef' or `#ifndef'.
   2821 
   2822 * Menu:
   2823 
   2824 * Ifdef::
   2825 * If::
   2826 * Defined::
   2827 * Else::
   2828 * Elif::
   2829 
   2830 
   2831 File: cpp.info,  Node: Ifdef,  Next: If,  Up: Conditional Syntax
   2832 
   2833 4.2.1 Ifdef
   2834 -----------
   2835 
   2836 The simplest sort of conditional is
   2837 
   2838      #ifdef MACRO
   2839 
   2840      CONTROLLED TEXT
   2841 
   2842      #endif /* MACRO */
   2843 
   2844    This block is called a "conditional group".  CONTROLLED TEXT will be
   2845 included in the output of the preprocessor if and only if MACRO is
   2846 defined.  We say that the conditional "succeeds" if MACRO is defined,
   2847 "fails" if it is not.
   2848 
   2849    The CONTROLLED TEXT inside of a conditional can include
   2850 preprocessing directives.  They are executed only if the conditional
   2851 succeeds.  You can nest conditional groups inside other conditional
   2852 groups, but they must be completely nested.  In other words, `#endif'
   2853 always matches the nearest `#ifdef' (or `#ifndef', or `#if').  Also,
   2854 you cannot start a conditional group in one file and end it in another.
   2855 
   2856    Even if a conditional fails, the CONTROLLED TEXT inside it is still
   2857 run through initial transformations and tokenization.  Therefore, it
   2858 must all be lexically valid C.  Normally the only way this matters is
   2859 that all comments and string literals inside a failing conditional group
   2860 must still be properly ended.
   2861 
   2862    The comment following the `#endif' is not required, but it is a good
   2863 practice if there is a lot of CONTROLLED TEXT, because it helps people
   2864 match the `#endif' to the corresponding `#ifdef'.  Older programs
   2865 sometimes put MACRO directly after the `#endif' without enclosing it in
   2866 a comment.  This is invalid code according to the C standard.  CPP
   2867 accepts it with a warning.  It never affects which `#ifndef' the
   2868 `#endif' matches.
   2869 
   2870    Sometimes you wish to use some code if a macro is _not_ defined.
   2871 You can do this by writing `#ifndef' instead of `#ifdef'.  One common
   2872 use of `#ifndef' is to include code only the first time a header file
   2873 is included.  *Note Once-Only Headers::.
   2874 
   2875    Macro definitions can vary between compilations for several reasons.
   2876 Here are some samples.
   2877 
   2878    * Some macros are predefined on each kind of machine (*note
   2879      System-specific Predefined Macros::).  This allows you to provide
   2880      code specially tuned for a particular machine.
   2881 
   2882    * System header files define more macros, associated with the
   2883      features they implement.  You can test these macros with
   2884      conditionals to avoid using a system feature on a machine where it
   2885      is not implemented.
   2886 
   2887    * Macros can be defined or undefined with the `-D' and `-U' command
   2888      line options when you compile the program.  You can arrange to
   2889      compile the same source file into two different programs by
   2890      choosing a macro name to specify which program you want, writing
   2891      conditionals to test whether or how this macro is defined, and
   2892      then controlling the state of the macro with command line options,
   2893      perhaps set in the Makefile.  *Note Invocation::.
   2894 
   2895    * Your program might have a special header file (often called
   2896      `config.h') that is adjusted when the program is compiled.  It can
   2897      define or not define macros depending on the features of the
   2898      system and the desired capabilities of the program.  The
   2899      adjustment can be automated by a tool such as `autoconf', or done
   2900      by hand.
   2901 
   2902 
   2903 File: cpp.info,  Node: If,  Next: Defined,  Prev: Ifdef,  Up: Conditional Syntax
   2904 
   2905 4.2.2 If
   2906 --------
   2907 
   2908 The `#if' directive allows you to test the value of an arithmetic
   2909 expression, rather than the mere existence of one macro.  Its syntax is
   2910 
   2911      #if EXPRESSION
   2912 
   2913      CONTROLLED TEXT
   2914 
   2915      #endif /* EXPRESSION */
   2916 
   2917    EXPRESSION is a C expression of integer type, subject to stringent
   2918 restrictions.  It may contain
   2919 
   2920    * Integer constants.
   2921 
   2922    * Character constants, which are interpreted as they would be in
   2923      normal code.
   2924 
   2925    * Arithmetic operators for addition, subtraction, multiplication,
   2926      division, bitwise operations, shifts, comparisons, and logical
   2927      operations (`&&' and `||').  The latter two obey the usual
   2928      short-circuiting rules of standard C.
   2929 
   2930    * Macros.  All macros in the expression are expanded before actual
   2931      computation of the expression's value begins.
   2932 
   2933    * Uses of the `defined' operator, which lets you check whether macros
   2934      are defined in the middle of an `#if'.
   2935 
   2936    * Identifiers that are not macros, which are all considered to be the
   2937      number zero.  This allows you to write `#if MACRO' instead of
   2938      `#ifdef MACRO', if you know that MACRO, when defined, will always
   2939      have a nonzero value.  Function-like macros used without their
   2940      function call parentheses are also treated as zero.
   2941 
   2942      In some contexts this shortcut is undesirable.  The `-Wundef'
   2943      option causes GCC to warn whenever it encounters an identifier
   2944      which is not a macro in an `#if'.
   2945 
   2946    The preprocessor does not know anything about types in the language.
   2947 Therefore, `sizeof' operators are not recognized in `#if', and neither
   2948 are `enum' constants.  They will be taken as identifiers which are not
   2949 macros, and replaced by zero.  In the case of `sizeof', this is likely
   2950 to cause the expression to be invalid.
   2951 
   2952    The preprocessor calculates the value of EXPRESSION.  It carries out
   2953 all calculations in the widest integer type known to the compiler; on
   2954 most machines supported by GCC this is 64 bits.  This is not the same
   2955 rule as the compiler uses to calculate the value of a constant
   2956 expression, and may give different results in some cases.  If the value
   2957 comes out to be nonzero, the `#if' succeeds and the CONTROLLED TEXT is
   2958 included; otherwise it is skipped.
   2959 
   2960 
   2961 File: cpp.info,  Node: Defined,  Next: Else,  Prev: If,  Up: Conditional Syntax
   2962 
   2963 4.2.3 Defined
   2964 -------------
   2965 
   2966 The special operator `defined' is used in `#if' and `#elif' expressions
   2967 to test whether a certain name is defined as a macro.  `defined NAME'
   2968 and `defined (NAME)' are both expressions whose value is 1 if NAME is
   2969 defined as a macro at the current point in the program, and 0
   2970 otherwise.  Thus,  `#if defined MACRO' is precisely equivalent to
   2971 `#ifdef MACRO'.
   2972 
   2973    `defined' is useful when you wish to test more than one macro for
   2974 existence at once.  For example,
   2975 
   2976      #if defined (__vax__) || defined (__ns16000__)
   2977 
   2978 would succeed if either of the names `__vax__' or `__ns16000__' is
   2979 defined as a macro.
   2980 
   2981    Conditionals written like this:
   2982 
   2983      #if defined BUFSIZE && BUFSIZE >= 1024
   2984 
   2985 can generally be simplified to just `#if BUFSIZE >= 1024', since if
   2986 `BUFSIZE' is not defined, it will be interpreted as having the value
   2987 zero.
   2988 
   2989    If the `defined' operator appears as a result of a macro expansion,
   2990 the C standard says the behavior is undefined.  GNU cpp treats it as a
   2991 genuine `defined' operator and evaluates it normally.  It will warn
   2992 wherever your code uses this feature if you use the command-line option
   2993 `-pedantic', since other compilers may handle it differently.
   2994 
   2995 
   2996 File: cpp.info,  Node: Else,  Next: Elif,  Prev: Defined,  Up: Conditional Syntax
   2997 
   2998 4.2.4 Else
   2999 ----------
   3000 
   3001 The `#else' directive can be added to a conditional to provide
   3002 alternative text to be used if the condition fails.  This is what it
   3003 looks like:
   3004 
   3005      #if EXPRESSION
   3006      TEXT-IF-TRUE
   3007      #else /* Not EXPRESSION */
   3008      TEXT-IF-FALSE
   3009      #endif /* Not EXPRESSION */
   3010 
   3011 If EXPRESSION is nonzero, the TEXT-IF-TRUE is included and the
   3012 TEXT-IF-FALSE is skipped.  If EXPRESSION is zero, the opposite happens.
   3013 
   3014    You can use `#else' with `#ifdef' and `#ifndef', too.
   3015 
   3016 
   3017 File: cpp.info,  Node: Elif,  Prev: Else,  Up: Conditional Syntax
   3018 
   3019 4.2.5 Elif
   3020 ----------
   3021 
   3022 One common case of nested conditionals is used to check for more than
   3023 two possible alternatives.  For example, you might have
   3024 
   3025      #if X == 1
   3026      ...
   3027      #else /* X != 1 */
   3028      #if X == 2
   3029      ...
   3030      #else /* X != 2 */
   3031      ...
   3032      #endif /* X != 2 */
   3033      #endif /* X != 1 */
   3034 
   3035    Another conditional directive, `#elif', allows this to be
   3036 abbreviated as follows:
   3037 
   3038      #if X == 1
   3039      ...
   3040      #elif X == 2
   3041      ...
   3042      #else /* X != 2 and X != 1*/
   3043      ...
   3044      #endif /* X != 2 and X != 1*/
   3045 
   3046    `#elif' stands for "else if".  Like `#else', it goes in the middle
   3047 of a conditional group and subdivides it; it does not require a
   3048 matching `#endif' of its own.  Like `#if', the `#elif' directive
   3049 includes an expression to be tested.  The text following the `#elif' is
   3050 processed only if the original `#if'-condition failed and the `#elif'
   3051 condition succeeds.
   3052 
   3053    More than one `#elif' can go in the same conditional group.  Then
   3054 the text after each `#elif' is processed only if the `#elif' condition
   3055 succeeds after the original `#if' and all previous `#elif' directives
   3056 within it have failed.
   3057 
   3058    `#else' is allowed after any number of `#elif' directives, but
   3059 `#elif' may not follow `#else'.
   3060 
   3061 
   3062 File: cpp.info,  Node: Deleted Code,  Prev: Conditional Syntax,  Up: Conditionals
   3063 
   3064 4.3 Deleted Code
   3065 ================
   3066 
   3067 If you replace or delete a part of the program but want to keep the old
   3068 code around for future reference, you often cannot simply comment it
   3069 out.  Block comments do not nest, so the first comment inside the old
   3070 code will end the commenting-out.  The probable result is a flood of
   3071 syntax errors.
   3072 
   3073    One way to avoid this problem is to use an always-false conditional
   3074 instead.  For instance, put `#if 0' before the deleted code and
   3075 `#endif' after it.  This works even if the code being turned off
   3076 contains conditionals, but they must be entire conditionals (balanced
   3077 `#if' and `#endif').
   3078 
   3079    Some people use `#ifdef notdef' instead.  This is risky, because
   3080 `notdef' might be accidentally defined as a macro, and then the
   3081 conditional would succeed.  `#if 0' can be counted on to fail.
   3082 
   3083    Do not use `#if 0' for comments which are not C code.  Use a real
   3084 comment, instead.  The interior of `#if 0' must consist of complete
   3085 tokens; in particular, single-quote characters must balance.  Comments
   3086 often contain unbalanced single-quote characters (known in English as
   3087 apostrophes).  These confuse `#if 0'.  They don't confuse `/*'.
   3088 
   3089 
   3090 File: cpp.info,  Node: Diagnostics,  Next: Line Control,  Prev: Conditionals,  Up: Top
   3091 
   3092 5 Diagnostics
   3093 *************
   3094 
   3095 The directive `#error' causes the preprocessor to report a fatal error.
   3096 The tokens forming the rest of the line following `#error' are used as
   3097 the error message.
   3098 
   3099    You would use `#error' inside of a conditional that detects a
   3100 combination of parameters which you know the program does not properly
   3101 support.  For example, if you know that the program will not run
   3102 properly on a VAX, you might write
   3103 
   3104      #ifdef __vax__
   3105      #error "Won't work on VAXen.  See comments at get_last_object."
   3106      #endif
   3107 
   3108    If you have several configuration parameters that must be set up by
   3109 the installation in a consistent way, you can use conditionals to detect
   3110 an inconsistency and report it with `#error'.  For example,
   3111 
   3112      #if !defined(UNALIGNED_INT_ASM_OP) && defined(DWARF2_DEBUGGING_INFO)
   3113      #error "DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP."
   3114      #endif
   3115 
   3116    The directive `#warning' is like `#error', but causes the
   3117 preprocessor to issue a warning and continue preprocessing.  The tokens
   3118 following `#warning' are used as the warning message.
   3119 
   3120    You might use `#warning' in obsolete header files, with a message
   3121 directing the user to the header file which should be used instead.
   3122 
   3123    Neither `#error' nor `#warning' macro-expands its argument.
   3124 Internal whitespace sequences are each replaced with a single space.
   3125 The line must consist of complete tokens.  It is wisest to make the
   3126 argument of these directives be a single string constant; this avoids
   3127 problems with apostrophes and the like.
   3128 
   3129 
   3130 File: cpp.info,  Node: Line Control,  Next: Pragmas,  Prev: Diagnostics,  Up: Top
   3131 
   3132 6 Line Control
   3133 **************
   3134 
   3135 The C preprocessor informs the C compiler of the location in your source
   3136 code where each token came from.  Presently, this is just the file name
   3137 and line number.  All the tokens resulting from macro expansion are
   3138 reported as having appeared on the line of the source file where the
   3139 outermost macro was used.  We intend to be more accurate in the future.
   3140 
   3141    If you write a program which generates source code, such as the
   3142 `bison' parser generator, you may want to adjust the preprocessor's
   3143 notion of the current file name and line number by hand.  Parts of the
   3144 output from `bison' are generated from scratch, other parts come from a
   3145 standard parser file.  The rest are copied verbatim from `bison''s
   3146 input.  You would like compiler error messages and symbolic debuggers
   3147 to be able to refer to `bison''s input file.
   3148 
   3149    `bison' or any such program can arrange this by writing `#line'
   3150 directives into the output file.  `#line' is a directive that specifies
   3151 the original line number and source file name for subsequent input in
   3152 the current preprocessor input file.  `#line' has three variants:
   3153 
   3154 `#line LINENUM'
   3155      LINENUM is a non-negative decimal integer constant.  It specifies
   3156      the line number which should be reported for the following line of
   3157      input.  Subsequent lines are counted from LINENUM.
   3158 
   3159 `#line LINENUM FILENAME'
   3160      LINENUM is the same as for the first form, and has the same
   3161      effect.  In addition, FILENAME is a string constant.  The
   3162      following line and all subsequent lines are reported to come from
   3163      the file it specifies, until something else happens to change that.
   3164      FILENAME is interpreted according to the normal rules for a string
   3165      constant: backslash escapes are interpreted.  This is different
   3166      from `#include'.
   3167 
   3168      Previous versions of CPP did not interpret escapes in `#line'; we
   3169      have changed it because the standard requires they be interpreted,
   3170      and most other compilers do.
   3171 
   3172 `#line ANYTHING ELSE'
   3173      ANYTHING ELSE is checked for macro calls, which are expanded.  The
   3174      result should match one of the above two forms.
   3175 
   3176    `#line' directives alter the results of the `__FILE__' and
   3177 `__LINE__' predefined macros from that point on.  *Note Standard
   3178 Predefined Macros::.  They do not have any effect on `#include''s idea
   3179 of the directory containing the current file.  This is a change from
   3180 GCC 2.95.  Previously, a file reading
   3181 
   3182      #line 1 "../src/gram.y"
   3183      #include "gram.h"
   3184 
   3185    would search for `gram.h' in `../src', then the `-I' chain; the
   3186 directory containing the physical source file would not be searched.
   3187 In GCC 3.0 and later, the `#include' is not affected by the presence of
   3188 a `#line' referring to a different directory.
   3189 
   3190    We made this change because the old behavior caused problems when
   3191 generated source files were transported between machines.  For instance,
   3192 it is common practice to ship generated parsers with a source release,
   3193 so that people building the distribution do not need to have yacc or
   3194 Bison installed.  These files frequently have `#line' directives
   3195 referring to the directory tree of the system where the distribution was
   3196 created.  If GCC tries to search for headers in those directories, the
   3197 build is likely to fail.
   3198 
   3199    The new behavior can cause failures too, if the generated file is not
   3200 in the same directory as its source and it attempts to include a header
   3201 which would be visible searching from the directory containing the
   3202 source file.  However, this problem is easily solved with an additional
   3203 `-I' switch on the command line.  The failures caused by the old
   3204 semantics could sometimes be corrected only by editing the generated
   3205 files, which is difficult and error-prone.
   3206 
   3207 
   3208 File: cpp.info,  Node: Pragmas,  Next: Other Directives,  Prev: Line Control,  Up: Top
   3209 
   3210 7 Pragmas
   3211 *********
   3212 
   3213 The `#pragma' directive is the method specified by the C standard for
   3214 providing additional information to the compiler, beyond what is
   3215 conveyed in the language itself.  Three forms of this directive
   3216 (commonly known as "pragmas") are specified by the 1999 C standard.  A
   3217 C compiler is free to attach any meaning it likes to other pragmas.
   3218 
   3219    GCC has historically preferred to use extensions to the syntax of the
   3220 language, such as `__attribute__', for this purpose.  However, GCC does
   3221 define a few pragmas of its own.  These mostly have effects on the
   3222 entire translation unit or source file.
   3223 
   3224    In GCC version 3, all GNU-defined, supported pragmas have been given
   3225 a `GCC' prefix.  This is in line with the `STDC' prefix on all pragmas
   3226 defined by C99.  For backward compatibility, pragmas which were
   3227 recognized by previous versions are still recognized without the `GCC'
   3228 prefix, but that usage is deprecated.  Some older pragmas are
   3229 deprecated in their entirety.  They are not recognized with the `GCC'
   3230 prefix.  *Note Obsolete Features::.
   3231 
   3232    C99 introduces the `_Pragma' operator.  This feature addresses a
   3233 major problem with `#pragma': being a directive, it cannot be produced
   3234 as the result of macro expansion.  `_Pragma' is an operator, much like
   3235 `sizeof' or `defined', and can be embedded in a macro.
   3236 
   3237    Its syntax is `_Pragma (STRING-LITERAL)', where STRING-LITERAL can
   3238 be either a normal or wide-character string literal.  It is
   3239 destringized, by replacing all `\\' with a single `\' and all `\"' with
   3240 a `"'.  The result is then processed as if it had appeared as the right
   3241 hand side of a `#pragma' directive.  For example,
   3242 
   3243      _Pragma ("GCC dependency \"parse.y\"")
   3244 
   3245 has the same effect as `#pragma GCC dependency "parse.y"'.  The same
   3246 effect could be achieved using macros, for example
   3247 
   3248      #define DO_PRAGMA(x) _Pragma (#x)
   3249      DO_PRAGMA (GCC dependency "parse.y")
   3250 
   3251    The standard is unclear on where a `_Pragma' operator can appear.
   3252 The preprocessor does not accept it within a preprocessing conditional
   3253 directive like `#if'.  To be safe, you are probably best keeping it out
   3254 of directives other than `#define', and putting it on a line of its own.
   3255 
   3256    This manual documents the pragmas which are meaningful to the
   3257 preprocessor itself.  Other pragmas are meaningful to the C or C++
   3258 compilers.  They are documented in the GCC manual.
   3259 
   3260    GCC plugins may provide their own pragmas.
   3261 
   3262 `#pragma GCC dependency'
   3263      `#pragma GCC dependency' allows you to check the relative dates of
   3264      the current file and another file.  If the other file is more
   3265      recent than the current file, a warning is issued.  This is useful
   3266      if the current file is derived from the other file, and should be
   3267      regenerated.  The other file is searched for using the normal
   3268      include search path.  Optional trailing text can be used to give
   3269      more information in the warning message.
   3270 
   3271           #pragma GCC dependency "parse.y"
   3272           #pragma GCC dependency "/usr/include/time.h" rerun fixincludes
   3273 
   3274 `#pragma GCC poison'
   3275      Sometimes, there is an identifier that you want to remove
   3276      completely from your program, and make sure that it never creeps
   3277      back in.  To enforce this, you can "poison" the identifier with
   3278      this pragma.  `#pragma GCC poison' is followed by a list of
   3279      identifiers to poison.  If any of those identifiers appears
   3280      anywhere in the source after the directive, it is a hard error.
   3281      For example,
   3282 
   3283           #pragma GCC poison printf sprintf fprintf
   3284           sprintf(some_string, "hello");
   3285 
   3286      will produce an error.
   3287 
   3288      If a poisoned identifier appears as part of the expansion of a
   3289      macro which was defined before the identifier was poisoned, it
   3290      will _not_ cause an error.  This lets you poison an identifier
   3291      without worrying about system headers defining macros that use it.
   3292 
   3293      For example,
   3294 
   3295           #define strrchr rindex
   3296           #pragma GCC poison rindex
   3297           strrchr(some_string, 'h');
   3298 
   3299      will not produce an error.
   3300 
   3301 `#pragma GCC system_header'
   3302      This pragma takes no arguments.  It causes the rest of the code in
   3303      the current file to be treated as if it came from a system header.
   3304      *Note System Headers::.
   3305 
   3306 
   3307 
   3308 File: cpp.info,  Node: Other Directives,  Next: Preprocessor Output,  Prev: Pragmas,  Up: Top
   3309 
   3310 8 Other Directives
   3311 ******************
   3312 
   3313 The `#ident' directive takes one argument, a string constant.  On some
   3314 systems, that string constant is copied into a special segment of the
   3315 object file.  On other systems, the directive is ignored.  The `#sccs'
   3316 directive is a synonym for `#ident'.
   3317 
   3318    These directives are not part of the C standard, but they are not
   3319 official GNU extensions either.  What historical information we have
   3320 been able to find, suggests they originated with System V.
   3321 
   3322    The "null directive" consists of a `#' followed by a newline, with
   3323 only whitespace (including comments) in between.  A null directive is
   3324 understood as a preprocessing directive but has no effect on the
   3325 preprocessor output.  The primary significance of the existence of the
   3326 null directive is that an input line consisting of just a `#' will
   3327 produce no output, rather than a line of output containing just a `#'.
   3328 Supposedly some old C programs contain such lines.
   3329 
   3330 
   3331 File: cpp.info,  Node: Preprocessor Output,  Next: Traditional Mode,  Prev: Other Directives,  Up: Top
   3332 
   3333 9 Preprocessor Output
   3334 *********************
   3335 
   3336 When the C preprocessor is used with the C, C++, or Objective-C
   3337 compilers, it is integrated into the compiler and communicates a stream
   3338 of binary tokens directly to the compiler's parser.  However, it can
   3339 also be used in the more conventional standalone mode, where it produces
   3340 textual output.
   3341 
   3342    The output from the C preprocessor looks much like the input, except
   3343 that all preprocessing directive lines have been replaced with blank
   3344 lines and all comments with spaces.  Long runs of blank lines are
   3345 discarded.
   3346 
   3347    The ISO standard specifies that it is implementation defined whether
   3348 a preprocessor preserves whitespace between tokens, or replaces it with
   3349 e.g. a single space.  In GNU CPP, whitespace between tokens is collapsed
   3350 to become a single space, with the exception that the first token on a
   3351 non-directive line is preceded with sufficient spaces that it appears in
   3352 the same column in the preprocessed output that it appeared in the
   3353 original source file.  This is so the output is easy to read.  *Note
   3354 Differences from previous versions::.  CPP does not insert any
   3355 whitespace where there was none in the original source, except where
   3356 necessary to prevent an accidental token paste.
   3357 
   3358    Source file name and line number information is conveyed by lines of
   3359 the form
   3360 
   3361      # LINENUM FILENAME FLAGS
   3362 
   3363 These are called "linemarkers".  They are inserted as needed into the
   3364 output (but never within a string or character constant).  They mean
   3365 that the following line originated in file FILENAME at line LINENUM.
   3366 FILENAME will never contain any non-printing characters; they are
   3367 replaced with octal escape sequences.
   3368 
   3369    After the file name comes zero or more flags, which are `1', `2',
   3370 `3', or `4'.  If there are multiple flags, spaces separate them.  Here
   3371 is what the flags mean:
   3372 
   3373 `1'
   3374      This indicates the start of a new file.
   3375 
   3376 `2'
   3377      This indicates returning to a file (after having included another
   3378      file).
   3379 
   3380 `3'
   3381      This indicates that the following text comes from a system header
   3382      file, so certain warnings should be suppressed.
   3383 
   3384 `4'
   3385      This indicates that the following text should be treated as being
   3386      wrapped in an implicit `extern "C"' block.
   3387 
   3388    As an extension, the preprocessor accepts linemarkers in
   3389 non-assembler input files.  They are treated like the corresponding
   3390 `#line' directive, (*note Line Control::), except that trailing flags
   3391 are permitted, and are interpreted with the meanings described above.
   3392 If multiple flags are given, they must be in ascending order.
   3393 
   3394    Some directives may be duplicated in the output of the preprocessor.
   3395 These are `#ident' (always), `#pragma' (only if the preprocessor does
   3396 not handle the pragma itself), and `#define' and `#undef' (with certain
   3397 debugging options).  If this happens, the `#' of the directive will
   3398 always be in the first column, and there will be no space between the
   3399 `#' and the directive name.  If macro expansion happens to generate
   3400 tokens which might be mistaken for a duplicated directive, a space will
   3401 be inserted between the `#' and the directive name.
   3402 
   3403 
   3404 File: cpp.info,  Node: Traditional Mode,  Next: Implementation Details,  Prev: Preprocessor Output,  Up: Top
   3405 
   3406 10 Traditional Mode
   3407 *******************
   3408 
   3409 Traditional (pre-standard) C preprocessing is rather different from the
   3410 preprocessing specified by the standard.  When GCC is given the
   3411 `-traditional-cpp' option, it attempts to emulate a traditional
   3412 preprocessor.
   3413 
   3414    GCC versions 3.2 and later only support traditional mode semantics in
   3415 the preprocessor, and not in the compiler front ends.  This chapter
   3416 outlines the traditional preprocessor semantics we implemented.
   3417 
   3418    The implementation does not correspond precisely to the behavior of
   3419 earlier versions of GCC, nor to any true traditional preprocessor.
   3420 After all, inconsistencies among traditional implementations were a
   3421 major motivation for C standardization.  However, we intend that it
   3422 should be compatible with true traditional preprocessors in all ways
   3423 that actually matter.
   3424 
   3425 * Menu:
   3426 
   3427 * Traditional lexical analysis::
   3428 * Traditional macros::
   3429 * Traditional miscellany::
   3430 * Traditional warnings::
   3431 
   3432 
   3433 File: cpp.info,  Node: Traditional lexical analysis,  Next: Traditional macros,  Up: Traditional Mode
   3434 
   3435 10.1 Traditional lexical analysis
   3436 =================================
   3437 
   3438 The traditional preprocessor does not decompose its input into tokens
   3439 the same way a standards-conforming preprocessor does.  The input is
   3440 simply treated as a stream of text with minimal internal form.
   3441 
   3442    This implementation does not treat trigraphs (*note trigraphs::)
   3443 specially since they were an invention of the standards committee.  It
   3444 handles arbitrarily-positioned escaped newlines properly and splices
   3445 the lines as you would expect; many traditional preprocessors did not
   3446 do this.
   3447 
   3448    The form of horizontal whitespace in the input file is preserved in
   3449 the output.  In particular, hard tabs remain hard tabs.  This can be
   3450 useful if, for example, you are preprocessing a Makefile.
   3451 
   3452    Traditional CPP only recognizes C-style block comments, and treats
   3453 the `/*' sequence as introducing a comment only if it lies outside
   3454 quoted text.  Quoted text is introduced by the usual single and double
   3455 quotes, and also by an initial `<' in a `#include' directive.
   3456 
   3457    Traditionally, comments are completely removed and are not replaced
   3458 with a space.  Since a traditional compiler does its own tokenization
   3459 of the output of the preprocessor, this means that comments can
   3460 effectively be used as token paste operators.  However, comments behave
   3461 like separators for text handled by the preprocessor itself, since it
   3462 doesn't re-lex its input.  For example, in
   3463 
   3464      #if foo/**/bar
   3465 
   3466 `foo' and `bar' are distinct identifiers and expanded separately if
   3467 they happen to be macros.  In other words, this directive is equivalent
   3468 to
   3469 
   3470      #if foo bar
   3471 
   3472 rather than
   3473 
   3474      #if foobar
   3475 
   3476    Generally speaking, in traditional mode an opening quote need not
   3477 have a matching closing quote.  In particular, a macro may be defined
   3478 with replacement text that contains an unmatched quote.  Of course, if
   3479 you attempt to compile preprocessed output containing an unmatched quote
   3480 you will get a syntax error.
   3481 
   3482    However, all preprocessing directives other than `#define' require
   3483 matching quotes.  For example:
   3484 
   3485      #define m This macro's fine and has an unmatched quote
   3486      "/* This is not a comment.  */
   3487      /* This is a comment.  The following #include directive
   3488         is ill-formed.  */
   3489      #include <stdio.h
   3490 
   3491    Just as for the ISO preprocessor, what would be a closing quote can
   3492 be escaped with a backslash to prevent the quoted text from closing.
   3493 
   3494 
   3495 File: cpp.info,  Node: Traditional macros,  Next: Traditional miscellany,  Prev: Traditional lexical analysis,  Up: Traditional Mode
   3496 
   3497 10.2 Traditional macros
   3498 =======================
   3499 
   3500 The major difference between traditional and ISO macros is that the
   3501 former expand to text rather than to a token sequence.  CPP removes all
   3502 leading and trailing horizontal whitespace from a macro's replacement
   3503 text before storing it, but preserves the form of internal whitespace.
   3504 
   3505    One consequence is that it is legitimate for the replacement text to
   3506 contain an unmatched quote (*note Traditional lexical analysis::).  An
   3507 unclosed string or character constant continues into the text following
   3508 the macro call.  Similarly, the text at the end of a macro's expansion
   3509 can run together with the text after the macro invocation to produce a
   3510 single token.
   3511 
   3512    Normally comments are removed from the replacement text after the
   3513 macro is expanded, but if the `-CC' option is passed on the command
   3514 line comments are preserved.  (In fact, the current implementation
   3515 removes comments even before saving the macro replacement text, but it
   3516 careful to do it in such a way that the observed effect is identical
   3517 even in the function-like macro case.)
   3518 
   3519    The ISO stringification operator `#' and token paste operator `##'
   3520 have no special meaning.  As explained later, an effect similar to
   3521 these operators can be obtained in a different way.  Macro names that
   3522 are embedded in quotes, either from the main file or after macro
   3523 replacement, do not expand.
   3524 
   3525    CPP replaces an unquoted object-like macro name with its replacement
   3526 text, and then rescans it for further macros to replace.  Unlike
   3527 standard macro expansion, traditional macro expansion has no provision
   3528 to prevent recursion.  If an object-like macro appears unquoted in its
   3529 replacement text, it will be replaced again during the rescan pass, and
   3530 so on _ad infinitum_.  GCC detects when it is expanding recursive
   3531 macros, emits an error message, and continues after the offending macro
   3532 invocation.
   3533 
   3534      #define PLUS +
   3535      #define INC(x) PLUS+x
   3536      INC(foo);
   3537           ==> ++foo;
   3538 
   3539    Function-like macros are similar in form but quite different in
   3540 behavior to their ISO counterparts.  Their arguments are contained
   3541 within parentheses, are comma-separated, and can cross physical lines.
   3542 Commas within nested parentheses are not treated as argument
   3543 separators.  Similarly, a quote in an argument cannot be left unclosed;
   3544 a following comma or parenthesis that comes before the closing quote is
   3545 treated like any other character.  There is no facility for handling
   3546 variadic macros.
   3547 
   3548    This implementation removes all comments from macro arguments, unless
   3549 the `-C' option is given.  The form of all other horizontal whitespace
   3550 in arguments is preserved, including leading and trailing whitespace.
   3551 In particular
   3552 
   3553      f( )
   3554 
   3555 is treated as an invocation of the macro `f' with a single argument
   3556 consisting of a single space.  If you want to invoke a function-like
   3557 macro that takes no arguments, you must not leave any whitespace
   3558 between the parentheses.
   3559 
   3560    If a macro argument crosses a new line, the new line is replaced with
   3561 a space when forming the argument.  If the previous line contained an
   3562 unterminated quote, the following line inherits the quoted state.
   3563 
   3564    Traditional preprocessors replace parameters in the replacement text
   3565 with their arguments regardless of whether the parameters are within
   3566 quotes or not.  This provides a way to stringize arguments.  For example
   3567 
   3568      #define str(x) "x"
   3569      str(/* A comment */some text )
   3570           ==> "some text "
   3571 
   3572 Note that the comment is removed, but that the trailing space is
   3573 preserved.  Here is an example of using a comment to effect token
   3574 pasting.
   3575 
   3576      #define suffix(x) foo_/**/x
   3577      suffix(bar)
   3578           ==> foo_bar
   3579 
   3580 
   3581 File: cpp.info,  Node: Traditional miscellany,  Next: Traditional warnings,  Prev: Traditional macros,  Up: Traditional Mode
   3582 
   3583 10.3 Traditional miscellany
   3584 ===========================
   3585 
   3586 Here are some things to be aware of when using the traditional
   3587 preprocessor.
   3588 
   3589    * Preprocessing directives are recognized only when their leading
   3590      `#' appears in the first column.  There can be no whitespace
   3591      between the beginning of the line and the `#', but whitespace can
   3592      follow the `#'.
   3593 
   3594    * A true traditional C preprocessor does not recognize `#error' or
   3595      `#pragma', and may not recognize `#elif'.  CPP supports all the
   3596      directives in traditional mode that it supports in ISO mode,
   3597      including extensions, with the exception that the effects of
   3598      `#pragma GCC poison' are undefined.
   3599 
   3600    * __STDC__ is not defined.
   3601 
   3602    * If you use digraphs the behavior is undefined.
   3603 
   3604    * If a line that looks like a directive appears within macro
   3605      arguments, the behavior is undefined.
   3606 
   3607 
   3608 
   3609 File: cpp.info,  Node: Traditional warnings,  Prev: Traditional miscellany,  Up: Traditional Mode
   3610 
   3611 10.4 Traditional warnings
   3612 =========================
   3613 
   3614 You can request warnings about features that did not exist, or worked
   3615 differently, in traditional C with the `-Wtraditional' option.  GCC
   3616 does not warn about features of ISO C which you must use when you are
   3617 using a conforming compiler, such as the `#' and `##' operators.
   3618 
   3619    Presently `-Wtraditional' warns about:
   3620 
   3621    * Macro parameters that appear within string literals in the macro
   3622      body.  In traditional C macro replacement takes place within
   3623      string literals, but does not in ISO C.
   3624 
   3625    * In traditional C, some preprocessor directives did not exist.
   3626      Traditional preprocessors would only consider a line to be a
   3627      directive if the `#' appeared in column 1 on the line.  Therefore
   3628      `-Wtraditional' warns about directives that traditional C
   3629      understands but would ignore because the `#' does not appear as the
   3630      first character on the line.  It also suggests you hide directives
   3631      like `#pragma' not understood by traditional C by indenting them.
   3632      Some traditional implementations would not recognize `#elif', so it
   3633      suggests avoiding it altogether.
   3634 
   3635    * A function-like macro that appears without an argument list.  In
   3636      some traditional preprocessors this was an error.  In ISO C it
   3637      merely means that the macro is not expanded.
   3638 
   3639    * The unary plus operator.  This did not exist in traditional C.
   3640 
   3641    * The `U' and `LL' integer constant suffixes, which were not
   3642      available in traditional C.  (Traditional C does support the `L'
   3643      suffix for simple long integer constants.)  You are not warned
   3644      about uses of these suffixes in macros defined in system headers.
   3645      For instance, `UINT_MAX' may well be defined as `4294967295U', but
   3646      you will not be warned if you use `UINT_MAX'.
   3647 
   3648      You can usually avoid the warning, and the related warning about
   3649      constants which are so large that they are unsigned, by writing the
   3650      integer constant in question in hexadecimal, with no U suffix.
   3651      Take care, though, because this gives the wrong result in exotic
   3652      cases.
   3653 
   3654 
   3655 File: cpp.info,  Node: Implementation Details,  Next: Invocation,  Prev: Traditional Mode,  Up: Top
   3656 
   3657 11 Implementation Details
   3658 *************************
   3659 
   3660 Here we document details of how the preprocessor's implementation
   3661 affects its user-visible behavior.  You should try to avoid undue
   3662 reliance on behavior described here, as it is possible that it will
   3663 change subtly in future implementations.
   3664 
   3665    Also documented here are obsolete features and changes from previous
   3666 versions of CPP.
   3667 
   3668 * Menu:
   3669 
   3670 * Implementation-defined behavior::
   3671 * Implementation limits::
   3672 * Obsolete Features::
   3673 * Differences from previous versions::
   3674 
   3675 
   3676 File: cpp.info,  Node: Implementation-defined behavior,  Next: Implementation limits,  Up: Implementation Details
   3677 
   3678 11.1 Implementation-defined behavior
   3679 ====================================
   3680 
   3681 This is how CPP behaves in all the cases which the C standard describes
   3682 as "implementation-defined".  This term means that the implementation
   3683 is free to do what it likes, but must document its choice and stick to
   3684 it.
   3685 
   3686    * The mapping of physical source file multi-byte characters to the
   3687      execution character set.
   3688 
   3689      The input character set can be specified using the
   3690      `-finput-charset' option, while the execution character set may be
   3691      controlled using the `-fexec-charset' and `-fwide-exec-charset'
   3692      options.
   3693 
   3694    * Identifier characters.  The C and C++ standards allow identifiers
   3695      to be composed of `_' and the alphanumeric characters.  C++ and
   3696      C99 also allow universal character names, and C99 further permits
   3697      implementation-defined characters.  GCC currently only permits
   3698      universal character names if `-fextended-identifiers' is used,
   3699      because the implementation of universal character names in
   3700      identifiers is experimental.
   3701 
   3702      GCC allows the `$' character in identifiers as an extension for
   3703      most targets.  This is true regardless of the `std=' switch, since
   3704      this extension cannot conflict with standards-conforming programs.
   3705      When preprocessing assembler, however, dollars are not identifier
   3706      characters by default.
   3707 
   3708      Currently the targets that by default do not permit `$' are AVR,
   3709      IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX
   3710      operating system.
   3711 
   3712      You can override the default with `-fdollars-in-identifiers' or
   3713      `fno-dollars-in-identifiers'.  *Note fdollars-in-identifiers::.
   3714 
   3715    * Non-empty sequences of whitespace characters.
   3716 
   3717      In textual output, each whitespace sequence is collapsed to a
   3718      single space.  For aesthetic reasons, the first token on each
   3719      non-directive line of output is preceded with sufficient spaces
   3720      that it appears in the same column as it did in the original
   3721      source file.
   3722 
   3723    * The numeric value of character constants in preprocessor
   3724      expressions.
   3725 
   3726      The preprocessor and compiler interpret character constants in the
   3727      same way; i.e. escape sequences such as `\a' are given the values
   3728      they would have on the target machine.
   3729 
   3730      The compiler evaluates a multi-character character constant a
   3731      character at a time, shifting the previous value left by the
   3732      number of bits per target character, and then or-ing in the
   3733      bit-pattern of the new character truncated to the width of a
   3734      target character.  The final bit-pattern is given type `int', and
   3735      is therefore signed, regardless of whether single characters are
   3736      signed or not (a slight change from versions 3.1 and earlier of
   3737      GCC).  If there are more characters in the constant than would fit
   3738      in the target `int' the compiler issues a warning, and the excess
   3739      leading characters are ignored.
   3740 
   3741      For example, `'ab'' for a target with an 8-bit `char' would be
   3742      interpreted as
   3743      `(int) ((unsigned char) 'a' * 256 + (unsigned char) 'b')', and
   3744      `'\234a'' as
   3745      `(int) ((unsigned char) '\234' * 256 + (unsigned char) 'a')'.
   3746 
   3747    * Source file inclusion.
   3748 
   3749      For a discussion on how the preprocessor locates header files,
   3750      *note Include Operation::.
   3751 
   3752    * Interpretation of the filename resulting from a macro-expanded
   3753      `#include' directive.
   3754 
   3755      *Note Computed Includes::.
   3756 
   3757    * Treatment of a `#pragma' directive that after macro-expansion
   3758      results in a standard pragma.
   3759 
   3760      No macro expansion occurs on any `#pragma' directive line, so the
   3761      question does not arise.
   3762 
   3763      Note that GCC does not yet implement any of the standard pragmas.
   3764 
   3765 
   3766 
   3767 File: cpp.info,  Node: Implementation limits,  Next: Obsolete Features,  Prev: Implementation-defined behavior,  Up: Implementation Details
   3768 
   3769 11.2 Implementation limits
   3770 ==========================
   3771 
   3772 CPP has a small number of internal limits.  This section lists the
   3773 limits which the C standard requires to be no lower than some minimum,
   3774 and all the others known.  It is intended that there should be as few
   3775 limits as possible.  If you encounter an undocumented or inconvenient
   3776 limit, please report that as a bug.  *Note Reporting Bugs: (gcc)Bugs.
   3777 
   3778    Where we say something is limited "only by available memory", that
   3779 means that internal data structures impose no intrinsic limit, and space
   3780 is allocated with `malloc' or equivalent.  The actual limit will
   3781 therefore depend on many things, such as the size of other things
   3782 allocated by the compiler at the same time, the amount of memory
   3783 consumed by other processes on the same computer, etc.
   3784 
   3785    * Nesting levels of `#include' files.
   3786 
   3787      We impose an arbitrary limit of 200 levels, to avoid runaway
   3788      recursion.  The standard requires at least 15 levels.
   3789 
   3790    * Nesting levels of conditional inclusion.
   3791 
   3792      The C standard mandates this be at least 63.  CPP is limited only
   3793      by available memory.
   3794 
   3795    * Levels of parenthesized expressions within a full expression.
   3796 
   3797      The C standard requires this to be at least 63.  In preprocessor
   3798      conditional expressions, it is limited only by available memory.
   3799 
   3800    * Significant initial characters in an identifier or macro name.
   3801 
   3802      The preprocessor treats all characters as significant.  The C
   3803      standard requires only that the first 63 be significant.
   3804 
   3805    * Number of macros simultaneously defined in a single translation
   3806      unit.
   3807 
   3808      The standard requires at least 4095 be possible.  CPP is limited
   3809      only by available memory.
   3810 
   3811    * Number of parameters in a macro definition and arguments in a
   3812      macro call.
   3813 
   3814      We allow `USHRT_MAX', which is no smaller than 65,535.  The minimum
   3815      required by the standard is 127.
   3816 
   3817    * Number of characters on a logical source line.
   3818 
   3819      The C standard requires a minimum of 4096 be permitted.  CPP places
   3820      no limits on this, but you may get incorrect column numbers
   3821      reported in diagnostics for lines longer than 65,535 characters.
   3822 
   3823    * Maximum size of a source file.
   3824 
   3825      The standard does not specify any lower limit on the maximum size
   3826      of a source file.  GNU cpp maps files into memory, so it is
   3827      limited by the available address space.  This is generally at
   3828      least two gigabytes.  Depending on the operating system, the size
   3829      of physical memory may or may not be a limitation.
   3830 
   3831 
   3832 
   3833 File: cpp.info,  Node: Obsolete Features,  Next: Differences from previous versions,  Prev: Implementation limits,  Up: Implementation Details
   3834 
   3835 11.3 Obsolete Features
   3836 ======================
   3837 
   3838 CPP has some features which are present mainly for compatibility with
   3839 older programs.  We discourage their use in new code.  In some cases,
   3840 we plan to remove the feature in a future version of GCC.
   3841 
   3842 11.3.1 Assertions
   3843 -----------------
   3844 
   3845 "Assertions" are a deprecated alternative to macros in writing
   3846 conditionals to test what sort of computer or system the compiled
   3847 program will run on.  Assertions are usually predefined, but you can
   3848 define them with preprocessing directives or command-line options.
   3849 
   3850    Assertions were intended to provide a more systematic way to describe
   3851 the compiler's target system and we added them for compatibility with
   3852 existing compilers.  In practice they are just as unpredictable as the
   3853 system-specific predefined macros.  In addition, they are not part of
   3854 any standard, and only a few compilers support them.  Therefore, the
   3855 use of assertions is *less* portable than the use of system-specific
   3856 predefined macros.  We recommend you do not use them at all.
   3857 
   3858    An assertion looks like this:
   3859 
   3860      #PREDICATE (ANSWER)
   3861 
   3862 PREDICATE must be a single identifier.  ANSWER can be any sequence of
   3863 tokens; all characters are significant except for leading and trailing
   3864 whitespace, and differences in internal whitespace sequences are
   3865 ignored.  (This is similar to the rules governing macro redefinition.)
   3866 Thus, `(x + y)' is different from `(x+y)' but equivalent to
   3867 `( x + y )'.  Parentheses do not nest inside an answer.
   3868 
   3869    To test an assertion, you write it in an `#if'.  For example, this
   3870 conditional succeeds if either `vax' or `ns16000' has been asserted as
   3871 an answer for `machine'.
   3872 
   3873      #if #machine (vax) || #machine (ns16000)
   3874 
   3875 You can test whether _any_ answer is asserted for a predicate by
   3876 omitting the answer in the conditional:
   3877 
   3878      #if #machine
   3879 
   3880    Assertions are made with the `#assert' directive.  Its sole argument
   3881 is the assertion to make, without the leading `#' that identifies
   3882 assertions in conditionals.
   3883 
   3884      #assert PREDICATE (ANSWER)
   3885 
   3886 You may make several assertions with the same predicate and different
   3887 answers.  Subsequent assertions do not override previous ones for the
   3888 same predicate.  All the answers for any given predicate are
   3889 simultaneously true.
   3890 
   3891    Assertions can be canceled with the `#unassert' directive.  It has
   3892 the same syntax as `#assert'.  In that form it cancels only the answer
   3893 which was specified on the `#unassert' line; other answers for that
   3894 predicate remain true.  You can cancel an entire predicate by leaving
   3895 out the answer:
   3896 
   3897      #unassert PREDICATE
   3898 
   3899 In either form, if no such assertion has been made, `#unassert' has no
   3900 effect.
   3901 
   3902    You can also make or cancel assertions using command line options.
   3903 *Note Invocation::.
   3904 
   3905 
   3906 File: cpp.info,  Node: Differences from previous versions,  Prev: Obsolete Features,  Up: Implementation Details
   3907 
   3908 11.4 Differences from previous versions
   3909 =======================================
   3910 
   3911 This section details behavior which has changed from previous versions
   3912 of CPP.  We do not plan to change it again in the near future, but we
   3913 do not promise not to, either.
   3914 
   3915    The "previous versions" discussed here are 2.95 and before.  The
   3916 behavior of GCC 3.0 is mostly the same as the behavior of the widely
   3917 used 2.96 and 2.97 development snapshots.  Where there are differences,
   3918 they generally represent bugs in the snapshots.
   3919 
   3920    * -I- deprecated
   3921 
   3922      This option has been deprecated in 4.0.  `-iquote' is meant to
   3923      replace the need for this option.
   3924 
   3925    * Order of evaluation of `#' and `##' operators
   3926 
   3927      The standard does not specify the order of evaluation of a chain of
   3928      `##' operators, nor whether `#' is evaluated before, after, or at
   3929      the same time as `##'.  You should therefore not write any code
   3930      which depends on any specific ordering.  It is possible to
   3931      guarantee an ordering, if you need one, by suitable use of nested
   3932      macros.
   3933 
   3934      An example of where this might matter is pasting the arguments `1',
   3935      `e' and `-2'.  This would be fine for left-to-right pasting, but
   3936      right-to-left pasting would produce an invalid token `e-2'.
   3937 
   3938      GCC 3.0 evaluates `#' and `##' at the same time and strictly left
   3939      to right.  Older versions evaluated all `#' operators first, then
   3940      all `##' operators, in an unreliable order.
   3941 
   3942    * The form of whitespace between tokens in preprocessor output
   3943 
   3944      *Note Preprocessor Output::, for the current textual format.  This
   3945      is also the format used by stringification.  Normally, the
   3946      preprocessor communicates tokens directly to the compiler's
   3947      parser, and whitespace does not come up at all.
   3948 
   3949      Older versions of GCC preserved all whitespace provided by the
   3950      user and inserted lots more whitespace of their own, because they
   3951      could not accurately predict when extra spaces were needed to
   3952      prevent accidental token pasting.
   3953 
   3954    * Optional argument when invoking rest argument macros
   3955 
   3956      As an extension, GCC permits you to omit the variable arguments
   3957      entirely when you use a variable argument macro.  This is
   3958      forbidden by the 1999 C standard, and will provoke a pedantic
   3959      warning with GCC 3.0.  Previous versions accepted it silently.
   3960 
   3961    * `##' swallowing preceding text in rest argument macros
   3962 
   3963      Formerly, in a macro expansion, if `##' appeared before a variable
   3964      arguments parameter, and the set of tokens specified for that
   3965      argument in the macro invocation was empty, previous versions of
   3966      CPP would back up and remove the preceding sequence of
   3967      non-whitespace characters (*not* the preceding token).  This
   3968      extension is in direct conflict with the 1999 C standard and has
   3969      been drastically pared back.
   3970 
   3971      In the current version of the preprocessor, if `##' appears between
   3972      a comma and a variable arguments parameter, and the variable
   3973      argument is omitted entirely, the comma will be removed from the
   3974      expansion.  If the variable argument is empty, or the token before
   3975      `##' is not a comma, then `##' behaves as a normal token paste.
   3976 
   3977    * `#line' and `#include'
   3978 
   3979      The `#line' directive used to change GCC's notion of the
   3980      "directory containing the current file", used by `#include' with a
   3981      double-quoted header file name.  In 3.0 and later, it does not.
   3982      *Note Line Control::, for further explanation.
   3983 
   3984    * Syntax of `#line'
   3985 
   3986      In GCC 2.95 and previous, the string constant argument to `#line'
   3987      was treated the same way as the argument to `#include': backslash
   3988      escapes were not honored, and the string ended at the second `"'.
   3989      This is not compliant with the C standard.  In GCC 3.0, an attempt
   3990      was made to correct the behavior, so that the string was treated
   3991      as a real string constant, but it turned out to be buggy.  In 3.1,
   3992      the bugs have been fixed.  (We are not fixing the bugs in 3.0
   3993      because they affect relatively few people and the fix is quite
   3994      invasive.)
   3995 
   3996 
   3997 
   3998 File: cpp.info,  Node: Invocation,  Next: Environment Variables,  Prev: Implementation Details,  Up: Top
   3999 
   4000 12 Invocation
   4001 *************
   4002 
   4003 Most often when you use the C preprocessor you will not have to invoke
   4004 it explicitly: the C compiler will do so automatically.  However, the
   4005 preprocessor is sometimes useful on its own.  All the options listed
   4006 here are also acceptable to the C compiler and have the same meaning,
   4007 except that the C compiler has different rules for specifying the output
   4008 file.
   4009 
   4010    _Note:_ Whether you use the preprocessor by way of `gcc' or `cpp',
   4011 the "compiler driver" is run first.  This program's purpose is to
   4012 translate your command into invocations of the programs that do the
   4013 actual work.  Their command line interfaces are similar but not
   4014 identical to the documented interface, and may change without notice.
   4015 
   4016    The C preprocessor expects two file names as arguments, INFILE and
   4017 OUTFILE.  The preprocessor reads INFILE together with any other files
   4018 it specifies with `#include'.  All the output generated by the combined
   4019 input files is written in OUTFILE.
   4020 
   4021    Either INFILE or OUTFILE may be `-', which as INFILE means to read
   4022 from standard input and as OUTFILE means to write to standard output.
   4023 Also, if either file is omitted, it means the same as if `-' had been
   4024 specified for that file.
   4025 
   4026    Unless otherwise noted, or the option ends in `=', all options which
   4027 take an argument may have that argument appear either immediately after
   4028 the option, or with a space between option and argument: `-Ifoo' and
   4029 `-I foo' have the same effect.
   4030 
   4031    Many options have multi-letter names; therefore multiple
   4032 single-letter options may _not_ be grouped: `-dM' is very different from
   4033 `-d -M'.
   4034 
   4035 `-D NAME'
   4036      Predefine NAME as a macro, with definition `1'.
   4037 
   4038 `-D NAME=DEFINITION'
   4039      The contents of DEFINITION are tokenized and processed as if they
   4040      appeared during translation phase three in a `#define' directive.
   4041      In particular, the definition will be truncated by embedded
   4042      newline characters.
   4043 
   4044      If you are invoking the preprocessor from a shell or shell-like
   4045      program you may need to use the shell's quoting syntax to protect
   4046      characters such as spaces that have a meaning in the shell syntax.
   4047 
   4048      If you wish to define a function-like macro on the command line,
   4049      write its argument list with surrounding parentheses before the
   4050      equals sign (if any).  Parentheses are meaningful to most shells,
   4051      so you will need to quote the option.  With `sh' and `csh',
   4052      `-D'NAME(ARGS...)=DEFINITION'' works.
   4053 
   4054      `-D' and `-U' options are processed in the order they are given on
   4055      the command line.  All `-imacros FILE' and `-include FILE' options
   4056      are processed after all `-D' and `-U' options.
   4057 
   4058 `-U NAME'
   4059      Cancel any previous definition of NAME, either built in or
   4060      provided with a `-D' option.
   4061 
   4062 `-undef'
   4063      Do not predefine any system-specific or GCC-specific macros.  The
   4064      standard predefined macros remain defined.  *Note Standard
   4065      Predefined Macros::.
   4066 
   4067 `-I DIR'
   4068      Add the directory DIR to the list of directories to be searched
   4069      for header files.  *Note Search Path::.  Directories named by `-I'
   4070      are searched before the standard system include directories.  If
   4071      the directory DIR is a standard system include directory, the
   4072      option is ignored to ensure that the default search order for
   4073      system directories and the special treatment of system headers are
   4074      not defeated (*note System Headers::) .  If DIR begins with `=',
   4075      then the `=' will be replaced by the sysroot prefix; see
   4076      `--sysroot' and `-isysroot'.
   4077 
   4078 `-o FILE'
   4079      Write output to FILE.  This is the same as specifying FILE as the
   4080      second non-option argument to `cpp'.  `gcc' has a different
   4081      interpretation of a second non-option argument, so you must use
   4082      `-o' to specify the output file.
   4083 
   4084 `-Wall'
   4085      Turns on all optional warnings which are desirable for normal code.
   4086      At present this is `-Wcomment', `-Wtrigraphs', `-Wmultichar' and a
   4087      warning about integer promotion causing a change of sign in `#if'
   4088      expressions.  Note that many of the preprocessor's warnings are on
   4089      by default and have no options to control them.
   4090 
   4091 `-Wcomment'
   4092 `-Wcomments'
   4093      Warn whenever a comment-start sequence `/*' appears in a `/*'
   4094      comment, or whenever a backslash-newline appears in a `//' comment.
   4095      (Both forms have the same effect.)
   4096 
   4097 `-Wtrigraphs'
   4098      Most trigraphs in comments cannot affect the meaning of the
   4099      program.  However, a trigraph that would form an escaped newline
   4100      (`??/' at the end of a line) can, by changing where the comment
   4101      begins or ends.  Therefore, only trigraphs that would form escaped
   4102      newlines produce warnings inside a comment.
   4103 
   4104      This option is implied by `-Wall'.  If `-Wall' is not given, this
   4105      option is still enabled unless trigraphs are enabled.  To get
   4106      trigraph conversion without warnings, but get the other `-Wall'
   4107      warnings, use `-trigraphs -Wall -Wno-trigraphs'.
   4108 
   4109 `-Wtraditional'
   4110      Warn about certain constructs that behave differently in
   4111      traditional and ISO C.  Also warn about ISO C constructs that have
   4112      no traditional C equivalent, and problematic constructs which
   4113      should be avoided.  *Note Traditional Mode::.
   4114 
   4115 `-Wundef'
   4116      Warn whenever an identifier which is not a macro is encountered in
   4117      an `#if' directive, outside of `defined'.  Such identifiers are
   4118      replaced with zero.
   4119 
   4120 `-Wunused-macros'
   4121      Warn about macros defined in the main file that are unused.  A
   4122      macro is "used" if it is expanded or tested for existence at least
   4123      once.  The preprocessor will also warn if the macro has not been
   4124      used at the time it is redefined or undefined.
   4125 
   4126      Built-in macros, macros defined on the command line, and macros
   4127      defined in include files are not warned about.
   4128 
   4129      _Note:_ If a macro is actually used, but only used in skipped
   4130      conditional blocks, then CPP will report it as unused.  To avoid
   4131      the warning in such a case, you might improve the scope of the
   4132      macro's definition by, for example, moving it into the first
   4133      skipped block.  Alternatively, you could provide a dummy use with
   4134      something like:
   4135 
   4136           #if defined the_macro_causing_the_warning
   4137           #endif
   4138 
   4139 `-Wendif-labels'
   4140      Warn whenever an `#else' or an `#endif' are followed by text.
   4141      This usually happens in code of the form
   4142 
   4143           #if FOO
   4144           ...
   4145           #else FOO
   4146           ...
   4147           #endif FOO
   4148 
   4149      The second and third `FOO' should be in comments, but often are not
   4150      in older programs.  This warning is on by default.
   4151 
   4152 `-Werror'
   4153      Make all warnings into hard errors.  Source code which triggers
   4154      warnings will be rejected.
   4155 
   4156 `-Wsystem-headers'
   4157      Issue warnings for code in system headers.  These are normally
   4158      unhelpful in finding bugs in your own code, therefore suppressed.
   4159      If you are responsible for the system library, you may want to see
   4160      them.
   4161 
   4162 `-w'
   4163      Suppress all warnings, including those which GNU CPP issues by
   4164      default.
   4165 
   4166 `-pedantic'
   4167      Issue all the mandatory diagnostics listed in the C standard.
   4168      Some of them are left out by default, since they trigger
   4169      frequently on harmless code.
   4170 
   4171 `-pedantic-errors'
   4172      Issue all the mandatory diagnostics, and make all mandatory
   4173      diagnostics into errors.  This includes mandatory diagnostics that
   4174      GCC issues without `-pedantic' but treats as warnings.
   4175 
   4176 `-M'
   4177      Instead of outputting the result of preprocessing, output a rule
   4178      suitable for `make' describing the dependencies of the main source
   4179      file.  The preprocessor outputs one `make' rule containing the
   4180      object file name for that source file, a colon, and the names of
   4181      all the included files, including those coming from `-include' or
   4182      `-imacros' command line options.
   4183 
   4184      Unless specified explicitly (with `-MT' or `-MQ'), the object file
   4185      name consists of the name of the source file with any suffix
   4186      replaced with object file suffix and with any leading directory
   4187      parts removed.  If there are many included files then the rule is
   4188      split into several lines using `\'-newline.  The rule has no
   4189      commands.
   4190 
   4191      This option does not suppress the preprocessor's debug output,
   4192      such as `-dM'.  To avoid mixing such debug output with the
   4193      dependency rules you should explicitly specify the dependency
   4194      output file with `-MF', or use an environment variable like
   4195      `DEPENDENCIES_OUTPUT' (*note Environment Variables::).  Debug
   4196      output will still be sent to the regular output stream as normal.
   4197 
   4198      Passing `-M' to the driver implies `-E', and suppresses warnings
   4199      with an implicit `-w'.
   4200 
   4201 `-MM'
   4202      Like `-M' but do not mention header files that are found in system
   4203      header directories, nor header files that are included, directly
   4204      or indirectly, from such a header.
   4205 
   4206      This implies that the choice of angle brackets or double quotes in
   4207      an `#include' directive does not in itself determine whether that
   4208      header will appear in `-MM' dependency output.  This is a slight
   4209      change in semantics from GCC versions 3.0 and earlier.
   4210 
   4211 `-MF FILE'
   4212      When used with `-M' or `-MM', specifies a file to write the
   4213      dependencies to.  If no `-MF' switch is given the preprocessor
   4214      sends the rules to the same place it would have sent preprocessed
   4215      output.
   4216 
   4217      When used with the driver options `-MD' or `-MMD', `-MF' overrides
   4218      the default dependency output file.
   4219 
   4220 `-MG'
   4221      In conjunction with an option such as `-M' requesting dependency
   4222      generation, `-MG' assumes missing header files are generated files
   4223      and adds them to the dependency list without raising an error.
   4224      The dependency filename is taken directly from the `#include'
   4225      directive without prepending any path.  `-MG' also suppresses
   4226      preprocessed output, as a missing header file renders this useless.
   4227 
   4228      This feature is used in automatic updating of makefiles.
   4229 
   4230 `-MP'
   4231      This option instructs CPP to add a phony target for each dependency
   4232      other than the main file, causing each to depend on nothing.  These
   4233      dummy rules work around errors `make' gives if you remove header
   4234      files without updating the `Makefile' to match.
   4235 
   4236      This is typical output:
   4237 
   4238           test.o: test.c test.h
   4239 
   4240           test.h:
   4241 
   4242 `-MT TARGET'
   4243      Change the target of the rule emitted by dependency generation.  By
   4244      default CPP takes the name of the main input file, deletes any
   4245      directory components and any file suffix such as `.c', and appends
   4246      the platform's usual object suffix.  The result is the target.
   4247 
   4248      An `-MT' option will set the target to be exactly the string you
   4249      specify.  If you want multiple targets, you can specify them as a
   4250      single argument to `-MT', or use multiple `-MT' options.
   4251 
   4252      For example, `-MT '$(objpfx)foo.o'' might give
   4253 
   4254           $(objpfx)foo.o: foo.c
   4255 
   4256 `-MQ TARGET'
   4257      Same as `-MT', but it quotes any characters which are special to
   4258      Make.  `-MQ '$(objpfx)foo.o'' gives
   4259 
   4260           $$(objpfx)foo.o: foo.c
   4261 
   4262      The default target is automatically quoted, as if it were given
   4263      with `-MQ'.
   4264 
   4265 `-MD'
   4266      `-MD' is equivalent to `-M -MF FILE', except that `-E' is not
   4267      implied.  The driver determines FILE based on whether an `-o'
   4268      option is given.  If it is, the driver uses its argument but with
   4269      a suffix of `.d', otherwise it takes the name of the input file,
   4270      removes any directory components and suffix, and applies a `.d'
   4271      suffix.
   4272 
   4273      If `-MD' is used in conjunction with `-E', any `-o' switch is
   4274      understood to specify the dependency output file (*note -MF:
   4275      dashMF.), but if used without `-E', each `-o' is understood to
   4276      specify a target object file.
   4277 
   4278      Since `-E' is not implied, `-MD' can be used to generate a
   4279      dependency output file as a side-effect of the compilation process.
   4280 
   4281 `-MMD'
   4282      Like `-MD' except mention only user header files, not system
   4283      header files.
   4284 
   4285 `-x c'
   4286 `-x c++'
   4287 `-x objective-c'
   4288 `-x assembler-with-cpp'
   4289      Specify the source language: C, C++, Objective-C, or assembly.
   4290      This has nothing to do with standards conformance or extensions;
   4291      it merely selects which base syntax to expect.  If you give none
   4292      of these options, cpp will deduce the language from the extension
   4293      of the source file: `.c', `.cc', `.m', or `.S'.  Some other common
   4294      extensions for C++ and assembly are also recognized.  If cpp does
   4295      not recognize the extension, it will treat the file as C; this is
   4296      the most generic mode.
   4297 
   4298      _Note:_ Previous versions of cpp accepted a `-lang' option which
   4299      selected both the language and the standards conformance level.
   4300      This option has been removed, because it conflicts with the `-l'
   4301      option.
   4302 
   4303 `-std=STANDARD'
   4304 `-ansi'
   4305      Specify the standard to which the code should conform.  Currently
   4306      CPP knows about C and C++ standards; others may be added in the
   4307      future.
   4308 
   4309      STANDARD may be one of:
   4310     `c90'
   4311     `c89'
   4312     `iso9899:1990'
   4313           The ISO C standard from 1990.  `c90' is the customary
   4314           shorthand for this version of the standard.
   4315 
   4316           The `-ansi' option is equivalent to `-std=c90'.
   4317 
   4318     `iso9899:199409'
   4319           The 1990 C standard, as amended in 1994.
   4320 
   4321     `iso9899:1999'
   4322     `c99'
   4323     `iso9899:199x'
   4324     `c9x'
   4325           The revised ISO C standard, published in December 1999.
   4326           Before publication, this was known as C9X.
   4327 
   4328     `c1x'
   4329           The next version of the ISO C standard, still under
   4330           development.
   4331 
   4332     `gnu90'
   4333     `gnu89'
   4334           The 1990 C standard plus GNU extensions.  This is the default.
   4335 
   4336     `gnu99'
   4337     `gnu9x'
   4338           The 1999 C standard plus GNU extensions.
   4339 
   4340     `gnu1x'
   4341           The next version of the ISO C standard, still under
   4342           development, plus GNU extensions.
   4343 
   4344     `c++98'
   4345           The 1998 ISO C++ standard plus amendments.
   4346 
   4347     `gnu++98'
   4348           The same as `-std=c++98' plus GNU extensions.  This is the
   4349           default for C++ code.
   4350 
   4351 `-I-'
   4352      Split the include path.  Any directories specified with `-I'
   4353      options before `-I-' are searched only for headers requested with
   4354      `#include "FILE"'; they are not searched for `#include <FILE>'.
   4355      If additional directories are specified with `-I' options after
   4356      the `-I-', those directories are searched for all `#include'
   4357      directives.
   4358 
   4359      In addition, `-I-' inhibits the use of the directory of the current
   4360      file directory as the first search directory for `#include "FILE"'.
   4361      *Note Search Path::.  This option has been deprecated.
   4362 
   4363 `-nostdinc'
   4364      Do not search the standard system directories for header files.
   4365      Only the directories you have specified with `-I' options (and the
   4366      directory of the current file, if appropriate) are searched.
   4367 
   4368 `-nostdinc++'
   4369      Do not search for header files in the C++-specific standard
   4370      directories, but do still search the other standard directories.
   4371      (This option is used when building the C++ library.)
   4372 
   4373 `-include FILE'
   4374      Process FILE as if `#include "file"' appeared as the first line of
   4375      the primary source file.  However, the first directory searched
   4376      for FILE is the preprocessor's working directory _instead of_ the
   4377      directory containing the main source file.  If not found there, it
   4378      is searched for in the remainder of the `#include "..."' search
   4379      chain as normal.
   4380 
   4381      If multiple `-include' options are given, the files are included
   4382      in the order they appear on the command line.
   4383 
   4384 `-imacros FILE'
   4385      Exactly like `-include', except that any output produced by
   4386      scanning FILE is thrown away.  Macros it defines remain defined.
   4387      This allows you to acquire all the macros from a header without
   4388      also processing its declarations.
   4389 
   4390      All files specified by `-imacros' are processed before all files
   4391      specified by `-include'.
   4392 
   4393 `-idirafter DIR'
   4394      Search DIR for header files, but do it _after_ all directories
   4395      specified with `-I' and the standard system directories have been
   4396      exhausted.  DIR is treated as a system include directory.  If DIR
   4397      begins with `=', then the `=' will be replaced by the sysroot
   4398      prefix; see `--sysroot' and `-isysroot'.
   4399 
   4400 `-iprefix PREFIX'
   4401      Specify PREFIX as the prefix for subsequent `-iwithprefix'
   4402      options.  If the prefix represents a directory, you should include
   4403      the final `/'.
   4404 
   4405 `-iwithprefix DIR'
   4406 `-iwithprefixbefore DIR'
   4407      Append DIR to the prefix specified previously with `-iprefix', and
   4408      add the resulting directory to the include search path.
   4409      `-iwithprefixbefore' puts it in the same place `-I' would;
   4410      `-iwithprefix' puts it where `-idirafter' would.
   4411 
   4412 `-isysroot DIR'
   4413      This option is like the `--sysroot' option, but applies only to
   4414      header files (except for Darwin targets, where it applies to both
   4415      header files and libraries).  See the `--sysroot' option for more
   4416      information.
   4417 
   4418 `-imultilib DIR'
   4419      Use DIR as a subdirectory of the directory containing
   4420      target-specific C++ headers.
   4421 
   4422 `-isystem DIR'
   4423      Search DIR for header files, after all directories specified by
   4424      `-I' but before the standard system directories.  Mark it as a
   4425      system directory, so that it gets the same special treatment as is
   4426      applied to the standard system directories.  *Note System
   4427      Headers::.  If DIR begins with `=', then the `=' will be replaced
   4428      by the sysroot prefix; see `--sysroot' and `-isysroot'.
   4429 
   4430 `-iquote DIR'
   4431      Search DIR only for header files requested with `#include "FILE"';
   4432      they are not searched for `#include <FILE>', before all
   4433      directories specified by `-I' and before the standard system
   4434      directories.  *Note Search Path::.  If DIR begins with `=', then
   4435      the `=' will be replaced by the sysroot prefix; see `--sysroot'
   4436      and `-isysroot'.
   4437 
   4438 `-fdirectives-only'
   4439      When preprocessing, handle directives, but do not expand macros.
   4440 
   4441      The option's behavior depends on the `-E' and `-fpreprocessed'
   4442      options.
   4443 
   4444      With `-E', preprocessing is limited to the handling of directives
   4445      such as `#define', `#ifdef', and `#error'.  Other preprocessor
   4446      operations, such as macro expansion and trigraph conversion are
   4447      not performed.  In addition, the `-dD' option is implicitly
   4448      enabled.
   4449 
   4450      With `-fpreprocessed', predefinition of command line and most
   4451      builtin macros is disabled.  Macros such as `__LINE__', which are
   4452      contextually dependent, are handled normally.  This enables
   4453      compilation of files previously preprocessed with `-E
   4454      -fdirectives-only'.
   4455 
   4456      With both `-E' and `-fpreprocessed', the rules for
   4457      `-fpreprocessed' take precedence.  This enables full preprocessing
   4458      of files previously preprocessed with `-E -fdirectives-only'.
   4459 
   4460 `-fdollars-in-identifiers'
   4461      Accept `$' in identifiers.  *Note Identifier characters::.
   4462 
   4463 `-fextended-identifiers'
   4464      Accept universal character names in identifiers.  This option is
   4465      experimental; in a future version of GCC, it will be enabled by
   4466      default for C99 and C++.
   4467 
   4468 `-fpreprocessed'
   4469      Indicate to the preprocessor that the input file has already been
   4470      preprocessed.  This suppresses things like macro expansion,
   4471      trigraph conversion, escaped newline splicing, and processing of
   4472      most directives.  The preprocessor still recognizes and removes
   4473      comments, so that you can pass a file preprocessed with `-C' to
   4474      the compiler without problems.  In this mode the integrated
   4475      preprocessor is little more than a tokenizer for the front ends.
   4476 
   4477      `-fpreprocessed' is implicit if the input file has one of the
   4478      extensions `.i', `.ii' or `.mi'.  These are the extensions that
   4479      GCC uses for preprocessed files created by `-save-temps'.
   4480 
   4481 `-ftabstop=WIDTH'
   4482      Set the distance between tab stops.  This helps the preprocessor
   4483      report correct column numbers in warnings or errors, even if tabs
   4484      appear on the line.  If the value is less than 1 or greater than
   4485      100, the option is ignored.  The default is 8.
   4486 
   4487 `-fexec-charset=CHARSET'
   4488      Set the execution character set, used for string and character
   4489      constants.  The default is UTF-8.  CHARSET can be any encoding
   4490      supported by the system's `iconv' library routine.
   4491 
   4492 `-fwide-exec-charset=CHARSET'
   4493      Set the wide execution character set, used for wide string and
   4494      character constants.  The default is UTF-32 or UTF-16, whichever
   4495      corresponds to the width of `wchar_t'.  As with `-fexec-charset',
   4496      CHARSET can be any encoding supported by the system's `iconv'
   4497      library routine; however, you will have problems with encodings
   4498      that do not fit exactly in `wchar_t'.
   4499 
   4500 `-finput-charset=CHARSET'
   4501      Set the input character set, used for translation from the
   4502      character set of the input file to the source character set used
   4503      by GCC.  If the locale does not specify, or GCC cannot get this
   4504      information from the locale, the default is UTF-8.  This can be
   4505      overridden by either the locale or this command line option.
   4506      Currently the command line option takes precedence if there's a
   4507      conflict.  CHARSET can be any encoding supported by the system's
   4508      `iconv' library routine.
   4509 
   4510 `-fworking-directory'
   4511      Enable generation of linemarkers in the preprocessor output that
   4512      will let the compiler know the current working directory at the
   4513      time of preprocessing.  When this option is enabled, the
   4514      preprocessor will emit, after the initial linemarker, a second
   4515      linemarker with the current working directory followed by two
   4516      slashes.  GCC will use this directory, when it's present in the
   4517      preprocessed input, as the directory emitted as the current
   4518      working directory in some debugging information formats.  This
   4519      option is implicitly enabled if debugging information is enabled,
   4520      but this can be inhibited with the negated form
   4521      `-fno-working-directory'.  If the `-P' flag is present in the
   4522      command line, this option has no effect, since no `#line'
   4523      directives are emitted whatsoever.
   4524 
   4525 `-fno-show-column'
   4526      Do not print column numbers in diagnostics.  This may be necessary
   4527      if diagnostics are being scanned by a program that does not
   4528      understand the column numbers, such as `dejagnu'.
   4529 
   4530 `-A PREDICATE=ANSWER'
   4531      Make an assertion with the predicate PREDICATE and answer ANSWER.
   4532      This form is preferred to the older form `-A PREDICATE(ANSWER)',
   4533      which is still supported, because it does not use shell special
   4534      characters.  *Note Obsolete Features::.
   4535 
   4536 `-A -PREDICATE=ANSWER'
   4537      Cancel an assertion with the predicate PREDICATE and answer ANSWER.
   4538 
   4539 `-dCHARS'
   4540      CHARS is a sequence of one or more of the following characters,
   4541      and must not be preceded by a space.  Other characters are
   4542      interpreted by the compiler proper, or reserved for future
   4543      versions of GCC, and so are silently ignored.  If you specify
   4544      characters whose behavior conflicts, the result is undefined.
   4545 
   4546     `M'
   4547           Instead of the normal output, generate a list of `#define'
   4548           directives for all the macros defined during the execution of
   4549           the preprocessor, including predefined macros.  This gives
   4550           you a way of finding out what is predefined in your version
   4551           of the preprocessor.  Assuming you have no file `foo.h', the
   4552           command
   4553 
   4554                touch foo.h; cpp -dM foo.h
   4555 
   4556           will show all the predefined macros.
   4557 
   4558           If you use `-dM' without the `-E' option, `-dM' is
   4559           interpreted as a synonym for `-fdump-rtl-mach'.  *Note
   4560           Debugging Options: (gcc)Debugging Options.
   4561 
   4562     `D'
   4563           Like `M' except in two respects: it does _not_ include the
   4564           predefined macros, and it outputs _both_ the `#define'
   4565           directives and the result of preprocessing.  Both kinds of
   4566           output go to the standard output file.
   4567 
   4568     `N'
   4569           Like `D', but emit only the macro names, not their expansions.
   4570 
   4571     `I'
   4572           Output `#include' directives in addition to the result of
   4573           preprocessing.
   4574 
   4575     `U'
   4576           Like `D' except that only macros that are expanded, or whose
   4577           definedness is tested in preprocessor directives, are output;
   4578           the output is delayed until the use or test of the macro; and
   4579           `#undef' directives are also output for macros tested but
   4580           undefined at the time.
   4581 
   4582 `-P'
   4583      Inhibit generation of linemarkers in the output from the
   4584      preprocessor.  This might be useful when running the preprocessor
   4585      on something that is not C code, and will be sent to a program
   4586      which might be confused by the linemarkers.  *Note Preprocessor
   4587      Output::.
   4588 
   4589 `-C'
   4590      Do not discard comments.  All comments are passed through to the
   4591      output file, except for comments in processed directives, which
   4592      are deleted along with the directive.
   4593 
   4594      You should be prepared for side effects when using `-C'; it causes
   4595      the preprocessor to treat comments as tokens in their own right.
   4596      For example, comments appearing at the start of what would be a
   4597      directive line have the effect of turning that line into an
   4598      ordinary source line, since the first token on the line is no
   4599      longer a `#'.
   4600 
   4601 `-CC'
   4602      Do not discard comments, including during macro expansion.  This is
   4603      like `-C', except that comments contained within macros are also
   4604      passed through to the output file where the macro is expanded.
   4605 
   4606      In addition to the side-effects of the `-C' option, the `-CC'
   4607      option causes all C++-style comments inside a macro to be
   4608      converted to C-style comments.  This is to prevent later use of
   4609      that macro from inadvertently commenting out the remainder of the
   4610      source line.
   4611 
   4612      The `-CC' option is generally used to support lint comments.
   4613 
   4614 `-traditional-cpp'
   4615      Try to imitate the behavior of old-fashioned C preprocessors, as
   4616      opposed to ISO C preprocessors.  *Note Traditional Mode::.
   4617 
   4618 `-trigraphs'
   4619      Process trigraph sequences.  *Note Initial processing::.
   4620 
   4621 `-remap'
   4622      Enable special code to work around file systems which only permit
   4623      very short file names, such as MS-DOS.
   4624 
   4625 `--help'
   4626 `--target-help'
   4627      Print text describing all the command line options instead of
   4628      preprocessing anything.
   4629 
   4630 `-v'
   4631      Verbose mode.  Print out GNU CPP's version number at the beginning
   4632      of execution, and report the final form of the include path.
   4633 
   4634 `-H'
   4635      Print the name of each header file used, in addition to other
   4636      normal activities.  Each name is indented to show how deep in the
   4637      `#include' stack it is.  Precompiled header files are also
   4638      printed, even if they are found to be invalid; an invalid
   4639      precompiled header file is printed with `...x' and a valid one
   4640      with `...!' .
   4641 
   4642 `-version'
   4643 `--version'
   4644      Print out GNU CPP's version number.  With one dash, proceed to
   4645      preprocess as normal.  With two dashes, exit immediately.
   4646 
   4647 
   4648 File: cpp.info,  Node: Environment Variables,  Next: GNU Free Documentation License,  Prev: Invocation,  Up: Top
   4649 
   4650 13 Environment Variables
   4651 ************************
   4652 
   4653 This section describes the environment variables that affect how CPP
   4654 operates.  You can use them to specify directories or prefixes to use
   4655 when searching for include files, or to control dependency output.
   4656 
   4657    Note that you can also specify places to search using options such as
   4658 `-I', and control dependency output with options like `-M' (*note
   4659 Invocation::).  These take precedence over environment variables, which
   4660 in turn take precedence over the configuration of GCC.
   4661 
   4662 `CPATH'
   4663 `C_INCLUDE_PATH'
   4664 `CPLUS_INCLUDE_PATH'
   4665 `OBJC_INCLUDE_PATH'
   4666      Each variable's value is a list of directories separated by a
   4667      special character, much like `PATH', in which to look for header
   4668      files.  The special character, `PATH_SEPARATOR', is
   4669      target-dependent and determined at GCC build time.  For Microsoft
   4670      Windows-based targets it is a semicolon, and for almost all other
   4671      targets it is a colon.
   4672 
   4673      `CPATH' specifies a list of directories to be searched as if
   4674      specified with `-I', but after any paths given with `-I' options
   4675      on the command line.  This environment variable is used regardless
   4676      of which language is being preprocessed.
   4677 
   4678      The remaining environment variables apply only when preprocessing
   4679      the particular language indicated.  Each specifies a list of
   4680      directories to be searched as if specified with `-isystem', but
   4681      after any paths given with `-isystem' options on the command line.
   4682 
   4683      In all these variables, an empty element instructs the compiler to
   4684      search its current working directory.  Empty elements can appear
   4685      at the beginning or end of a path.  For instance, if the value of
   4686      `CPATH' is `:/special/include', that has the same effect as
   4687      `-I. -I/special/include'.
   4688 
   4689      See also *note Search Path::.
   4690 
   4691 `DEPENDENCIES_OUTPUT'
   4692      If this variable is set, its value specifies how to output
   4693      dependencies for Make based on the non-system header files
   4694      processed by the compiler.  System header files are ignored in the
   4695      dependency output.
   4696 
   4697      The value of `DEPENDENCIES_OUTPUT' can be just a file name, in
   4698      which case the Make rules are written to that file, guessing the
   4699      target name from the source file name.  Or the value can have the
   4700      form `FILE TARGET', in which case the rules are written to file
   4701      FILE using TARGET as the target name.
   4702 
   4703      In other words, this environment variable is equivalent to
   4704      combining the options `-MM' and `-MF' (*note Invocation::), with
   4705      an optional `-MT' switch too.
   4706 
   4707 `SUNPRO_DEPENDENCIES'
   4708      This variable is the same as `DEPENDENCIES_OUTPUT' (see above),
   4709      except that system header files are not ignored, so it implies
   4710      `-M' rather than `-MM'.  However, the dependence on the main input
   4711      file is omitted.  *Note Invocation::.
   4712 
   4713 
   4714 File: cpp.info,  Node: GNU Free Documentation License,  Next: Index of Directives,  Prev: Environment Variables,  Up: Top
   4715 
   4716 GNU Free Documentation License
   4717 ******************************
   4718 
   4719                      Version 1.3, 3 November 2008
   4720 
   4721      Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
   4722      `http://fsf.org/'
   4723 
   4724      Everyone is permitted to copy and distribute verbatim copies
   4725      of this license document, but changing it is not allowed.
   4726 
   4727   0. PREAMBLE
   4728 
   4729      The purpose of this License is to make a manual, textbook, or other
   4730      functional and useful document "free" in the sense of freedom: to
   4731      assure everyone the effective freedom to copy and redistribute it,
   4732      with or without modifying it, either commercially or
   4733      noncommercially.  Secondarily, this License preserves for the
   4734      author and publisher a way to get credit for their work, while not
   4735      being considered responsible for modifications made by others.
   4736 
   4737      This License is a kind of "copyleft", which means that derivative
   4738      works of the document must themselves be free in the same sense.
   4739      It complements the GNU General Public License, which is a copyleft
   4740      license designed for free software.
   4741 
   4742      We have designed this License in order to use it for manuals for
   4743      free software, because free software needs free documentation: a
   4744      free program should come with manuals providing the same freedoms
   4745      that the software does.  But this License is not limited to
   4746      software manuals; it can be used for any textual work, regardless
   4747      of subject matter or whether it is published as a printed book.
   4748      We recommend this License principally for works whose purpose is
   4749      instruction or reference.
   4750 
   4751   1. APPLICABILITY AND DEFINITIONS
   4752 
   4753      This License applies to any manual or other work, in any medium,
   4754      that contains a notice placed by the copyright holder saying it
   4755      can be distributed under the terms of this License.  Such a notice
   4756      grants a world-wide, royalty-free license, unlimited in duration,
   4757      to use that work under the conditions stated herein.  The
   4758      "Document", below, refers to any such manual or work.  Any member
   4759      of the public is a licensee, and is addressed as "you".  You
   4760      accept the license if you copy, modify or distribute the work in a
   4761      way requiring permission under copyright law.
   4762 
   4763      A "Modified Version" of the Document means any work containing the
   4764      Document or a portion of it, either copied verbatim, or with
   4765      modifications and/or translated into another language.
   4766 
   4767      A "Secondary Section" is a named appendix or a front-matter section
   4768      of the Document that deals exclusively with the relationship of the
   4769      publishers or authors of the Document to the Document's overall
   4770      subject (or to related matters) and contains nothing that could
   4771      fall directly within that overall subject.  (Thus, if the Document
   4772      is in part a textbook of mathematics, a Secondary Section may not
   4773      explain any mathematics.)  The relationship could be a matter of
   4774      historical connection with the subject or with related matters, or
   4775      of legal, commercial, philosophical, ethical or political position
   4776      regarding them.
   4777 
   4778      The "Invariant Sections" are certain Secondary Sections whose
   4779      titles are designated, as being those of Invariant Sections, in
   4780      the notice that says that the Document is released under this
   4781      License.  If a section does not fit the above definition of
   4782      Secondary then it is not allowed to be designated as Invariant.
   4783      The Document may contain zero Invariant Sections.  If the Document
   4784      does not identify any Invariant Sections then there are none.
   4785 
   4786      The "Cover Texts" are certain short passages of text that are
   4787      listed, as Front-Cover Texts or Back-Cover Texts, in the notice
   4788      that says that the Document is released under this License.  A
   4789      Front-Cover Text may be at most 5 words, and a Back-Cover Text may
   4790      be at most 25 words.
   4791 
   4792      A "Transparent" copy of the Document means a machine-readable copy,
   4793      represented in a format whose specification is available to the
   4794      general public, that is suitable for revising the document
   4795      straightforwardly with generic text editors or (for images
   4796      composed of pixels) generic paint programs or (for drawings) some
   4797      widely available drawing editor, and that is suitable for input to
   4798      text formatters or for automatic translation to a variety of
   4799      formats suitable for input to text formatters.  A copy made in an
   4800      otherwise Transparent file format whose markup, or absence of
   4801      markup, has been arranged to thwart or discourage subsequent
   4802      modification by readers is not Transparent.  An image format is
   4803      not Transparent if used for any substantial amount of text.  A
   4804      copy that is not "Transparent" is called "Opaque".
   4805 
   4806      Examples of suitable formats for Transparent copies include plain
   4807      ASCII without markup, Texinfo input format, LaTeX input format,
   4808      SGML or XML using a publicly available DTD, and
   4809      standard-conforming simple HTML, PostScript or PDF designed for
   4810      human modification.  Examples of transparent image formats include
   4811      PNG, XCF and JPG.  Opaque formats include proprietary formats that
   4812      can be read and edited only by proprietary word processors, SGML or
   4813      XML for which the DTD and/or processing tools are not generally
   4814      available, and the machine-generated HTML, PostScript or PDF
   4815      produced by some word processors for output purposes only.
   4816 
   4817      The "Title Page" means, for a printed book, the title page itself,
   4818      plus such following pages as are needed to hold, legibly, the
   4819      material this License requires to appear in the title page.  For
   4820      works in formats which do not have any title page as such, "Title
   4821      Page" means the text near the most prominent appearance of the
   4822      work's title, preceding the beginning of the body of the text.
   4823 
   4824      The "publisher" means any person or entity that distributes copies
   4825      of the Document to the public.
   4826 
   4827      A section "Entitled XYZ" means a named subunit of the Document
   4828      whose title either is precisely XYZ or contains XYZ in parentheses
   4829      following text that translates XYZ in another language.  (Here XYZ
   4830      stands for a specific section name mentioned below, such as
   4831      "Acknowledgements", "Dedications", "Endorsements", or "History".)
   4832      To "Preserve the Title" of such a section when you modify the
   4833      Document means that it remains a section "Entitled XYZ" according
   4834      to this definition.
   4835 
   4836      The Document may include Warranty Disclaimers next to the notice
   4837      which states that this License applies to the Document.  These
   4838      Warranty Disclaimers are considered to be included by reference in
   4839      this License, but only as regards disclaiming warranties: any other
   4840      implication that these Warranty Disclaimers may have is void and
   4841      has no effect on the meaning of this License.
   4842 
   4843   2. VERBATIM COPYING
   4844 
   4845      You may copy and distribute the Document in any medium, either
   4846      commercially or noncommercially, provided that this License, the
   4847      copyright notices, and the license notice saying this License
   4848      applies to the Document are reproduced in all copies, and that you
   4849      add no other conditions whatsoever to those of this License.  You
   4850      may not use technical measures to obstruct or control the reading
   4851      or further copying of the copies you make or distribute.  However,
   4852      you may accept compensation in exchange for copies.  If you
   4853      distribute a large enough number of copies you must also follow
   4854      the conditions in section 3.
   4855 
   4856      You may also lend copies, under the same conditions stated above,
   4857      and you may publicly display copies.
   4858 
   4859   3. COPYING IN QUANTITY
   4860 
   4861      If you publish printed copies (or copies in media that commonly
   4862      have printed covers) of the Document, numbering more than 100, and
   4863      the Document's license notice requires Cover Texts, you must
   4864      enclose the copies in covers that carry, clearly and legibly, all
   4865      these Cover Texts: Front-Cover Texts on the front cover, and
   4866      Back-Cover Texts on the back cover.  Both covers must also clearly
   4867      and legibly identify you as the publisher of these copies.  The
   4868      front cover must present the full title with all words of the
   4869      title equally prominent and visible.  You may add other material
   4870      on the covers in addition.  Copying with changes limited to the
   4871      covers, as long as they preserve the title of the Document and
   4872      satisfy these conditions, can be treated as verbatim copying in
   4873      other respects.
   4874 
   4875      If the required texts for either cover are too voluminous to fit
   4876      legibly, you should put the first ones listed (as many as fit
   4877      reasonably) on the actual cover, and continue the rest onto
   4878      adjacent pages.
   4879 
   4880      If you publish or distribute Opaque copies of the Document
   4881      numbering more than 100, you must either include a
   4882      machine-readable Transparent copy along with each Opaque copy, or
   4883      state in or with each Opaque copy a computer-network location from
   4884      which the general network-using public has access to download
   4885      using public-standard network protocols a complete Transparent
   4886      copy of the Document, free of added material.  If you use the
   4887      latter option, you must take reasonably prudent steps, when you
   4888      begin distribution of Opaque copies in quantity, to ensure that
   4889      this Transparent copy will remain thus accessible at the stated
   4890      location until at least one year after the last time you
   4891      distribute an Opaque copy (directly or through your agents or
   4892      retailers) of that edition to the public.
   4893 
   4894      It is requested, but not required, that you contact the authors of
   4895      the Document well before redistributing any large number of
   4896      copies, to give them a chance to provide you with an updated
   4897      version of the Document.
   4898 
   4899   4. MODIFICATIONS
   4900 
   4901      You may copy and distribute a Modified Version of the Document
   4902      under the conditions of sections 2 and 3 above, provided that you
   4903      release the Modified Version under precisely this License, with
   4904      the Modified Version filling the role of the Document, thus
   4905      licensing distribution and modification of the Modified Version to
   4906      whoever possesses a copy of it.  In addition, you must do these
   4907      things in the Modified Version:
   4908 
   4909        A. Use in the Title Page (and on the covers, if any) a title
   4910           distinct from that of the Document, and from those of
   4911           previous versions (which should, if there were any, be listed
   4912           in the History section of the Document).  You may use the
   4913           same title as a previous version if the original publisher of
   4914           that version gives permission.
   4915 
   4916        B. List on the Title Page, as authors, one or more persons or
   4917           entities responsible for authorship of the modifications in
   4918           the Modified Version, together with at least five of the
   4919           principal authors of the Document (all of its principal
   4920           authors, if it has fewer than five), unless they release you
   4921           from this requirement.
   4922 
   4923        C. State on the Title page the name of the publisher of the
   4924           Modified Version, as the publisher.
   4925 
   4926        D. Preserve all the copyright notices of the Document.
   4927 
   4928        E. Add an appropriate copyright notice for your modifications
   4929           adjacent to the other copyright notices.
   4930 
   4931        F. Include, immediately after the copyright notices, a license
   4932           notice giving the public permission to use the Modified
   4933           Version under the terms of this License, in the form shown in
   4934           the Addendum below.
   4935 
   4936        G. Preserve in that license notice the full lists of Invariant
   4937           Sections and required Cover Texts given in the Document's
   4938           license notice.
   4939 
   4940        H. Include an unaltered copy of this License.
   4941 
   4942        I. Preserve the section Entitled "History", Preserve its Title,
   4943           and add to it an item stating at least the title, year, new
   4944           authors, and publisher of the Modified Version as given on
   4945           the Title Page.  If there is no section Entitled "History" in
   4946           the Document, create one stating the title, year, authors,
   4947           and publisher of the Document as given on its Title Page,
   4948           then add an item describing the Modified Version as stated in
   4949           the previous sentence.
   4950 
   4951        J. Preserve the network location, if any, given in the Document
   4952           for public access to a Transparent copy of the Document, and
   4953           likewise the network locations given in the Document for
   4954           previous versions it was based on.  These may be placed in
   4955           the "History" section.  You may omit a network location for a
   4956           work that was published at least four years before the
   4957           Document itself, or if the original publisher of the version
   4958           it refers to gives permission.
   4959 
   4960        K. For any section Entitled "Acknowledgements" or "Dedications",
   4961           Preserve the Title of the section, and preserve in the
   4962           section all the substance and tone of each of the contributor
   4963           acknowledgements and/or dedications given therein.
   4964 
   4965        L. Preserve all the Invariant Sections of the Document,
   4966           unaltered in their text and in their titles.  Section numbers
   4967           or the equivalent are not considered part of the section
   4968           titles.
   4969 
   4970        M. Delete any section Entitled "Endorsements".  Such a section
   4971           may not be included in the Modified Version.
   4972 
   4973        N. Do not retitle any existing section to be Entitled
   4974           "Endorsements" or to conflict in title with any Invariant
   4975           Section.
   4976 
   4977        O. Preserve any Warranty Disclaimers.
   4978 
   4979      If the Modified Version includes new front-matter sections or
   4980      appendices that qualify as Secondary Sections and contain no
   4981      material copied from the Document, you may at your option
   4982      designate some or all of these sections as invariant.  To do this,
   4983      add their titles to the list of Invariant Sections in the Modified
   4984      Version's license notice.  These titles must be distinct from any
   4985      other section titles.
   4986 
   4987      You may add a section Entitled "Endorsements", provided it contains
   4988      nothing but endorsements of your Modified Version by various
   4989      parties--for example, statements of peer review or that the text
   4990      has been approved by an organization as the authoritative
   4991      definition of a standard.
   4992 
   4993      You may add a passage of up to five words as a Front-Cover Text,
   4994      and a passage of up to 25 words as a Back-Cover Text, to the end
   4995      of the list of Cover Texts in the Modified Version.  Only one
   4996      passage of Front-Cover Text and one of Back-Cover Text may be
   4997      added by (or through arrangements made by) any one entity.  If the
   4998      Document already includes a cover text for the same cover,
   4999      previously added by you or by arrangement made by the same entity
   5000      you are acting on behalf of, you may not add another; but you may
   5001      replace the old one, on explicit permission from the previous
   5002      publisher that added the old one.
   5003 
   5004      The author(s) and publisher(s) of the Document do not by this
   5005      License give permission to use their names for publicity for or to
   5006      assert or imply endorsement of any Modified Version.
   5007 
   5008   5. COMBINING DOCUMENTS
   5009 
   5010      You may combine the Document with other documents released under
   5011      this License, under the terms defined in section 4 above for
   5012      modified versions, provided that you include in the combination
   5013      all of the Invariant Sections of all of the original documents,
   5014      unmodified, and list them all as Invariant Sections of your
   5015      combined work in its license notice, and that you preserve all
   5016      their Warranty Disclaimers.
   5017 
   5018      The combined work need only contain one copy of this License, and
   5019      multiple identical Invariant Sections may be replaced with a single
   5020      copy.  If there are multiple Invariant Sections with the same name
   5021      but different contents, make the title of each such section unique
   5022      by adding at the end of it, in parentheses, the name of the
   5023      original author or publisher of that section if known, or else a
   5024      unique number.  Make the same adjustment to the section titles in
   5025      the list of Invariant Sections in the license notice of the
   5026      combined work.
   5027 
   5028      In the combination, you must combine any sections Entitled
   5029      "History" in the various original documents, forming one section
   5030      Entitled "History"; likewise combine any sections Entitled
   5031      "Acknowledgements", and any sections Entitled "Dedications".  You
   5032      must delete all sections Entitled "Endorsements."
   5033 
   5034   6. COLLECTIONS OF DOCUMENTS
   5035 
   5036      You may make a collection consisting of the Document and other
   5037      documents released under this License, and replace the individual
   5038      copies of this License in the various documents with a single copy
   5039      that is included in the collection, provided that you follow the
   5040      rules of this License for verbatim copying of each of the
   5041      documents in all other respects.
   5042 
   5043      You may extract a single document from such a collection, and
   5044      distribute it individually under this License, provided you insert
   5045      a copy of this License into the extracted document, and follow
   5046      this License in all other respects regarding verbatim copying of
   5047      that document.
   5048 
   5049   7. AGGREGATION WITH INDEPENDENT WORKS
   5050 
   5051      A compilation of the Document or its derivatives with other
   5052      separate and independent documents or works, in or on a volume of
   5053      a storage or distribution medium, is called an "aggregate" if the
   5054      copyright resulting from the compilation is not used to limit the
   5055      legal rights of the compilation's users beyond what the individual
   5056      works permit.  When the Document is included in an aggregate, this
   5057      License does not apply to the other works in the aggregate which
   5058      are not themselves derivative works of the Document.
   5059 
   5060      If the Cover Text requirement of section 3 is applicable to these
   5061      copies of the Document, then if the Document is less than one half
   5062      of the entire aggregate, the Document's Cover Texts may be placed
   5063      on covers that bracket the Document within the aggregate, or the
   5064      electronic equivalent of covers if the Document is in electronic
   5065      form.  Otherwise they must appear on printed covers that bracket
   5066      the whole aggregate.
   5067 
   5068   8. TRANSLATION
   5069 
   5070      Translation is considered a kind of modification, so you may
   5071      distribute translations of the Document under the terms of section
   5072      4.  Replacing Invariant Sections with translations requires special
   5073      permission from their copyright holders, but you may include
   5074      translations of some or all Invariant Sections in addition to the
   5075      original versions of these Invariant Sections.  You may include a
   5076      translation of this License, and all the license notices in the
   5077      Document, and any Warranty Disclaimers, provided that you also
   5078      include the original English version of this License and the
   5079      original versions of those notices and disclaimers.  In case of a
   5080      disagreement between the translation and the original version of
   5081      this License or a notice or disclaimer, the original version will
   5082      prevail.
   5083 
   5084      If a section in the Document is Entitled "Acknowledgements",
   5085      "Dedications", or "History", the requirement (section 4) to
   5086      Preserve its Title (section 1) will typically require changing the
   5087      actual title.
   5088 
   5089   9. TERMINATION
   5090 
   5091      You may not copy, modify, sublicense, or distribute the Document
   5092      except as expressly provided under this License.  Any attempt
   5093      otherwise to copy, modify, sublicense, or distribute it is void,
   5094      and will automatically terminate your rights under this License.
   5095 
   5096      However, if you cease all violation of this License, then your
   5097      license from a particular copyright holder is reinstated (a)
   5098      provisionally, unless and until the copyright holder explicitly
   5099      and finally terminates your license, and (b) permanently, if the
   5100      copyright holder fails to notify you of the violation by some
   5101      reasonable means prior to 60 days after the cessation.
   5102 
   5103      Moreover, your license from a particular copyright holder is
   5104      reinstated permanently if the copyright holder notifies you of the
   5105      violation by some reasonable means, this is the first time you have
   5106      received notice of violation of this License (for any work) from
   5107      that copyright holder, and you cure the violation prior to 30 days
   5108      after your receipt of the notice.
   5109 
   5110      Termination of your rights under this section does not terminate
   5111      the licenses of parties who have received copies or rights from
   5112      you under this License.  If your rights have been terminated and
   5113      not permanently reinstated, receipt of a copy of some or all of
   5114      the same material does not give you any rights to use it.
   5115 
   5116  10. FUTURE REVISIONS OF THIS LICENSE
   5117 
   5118      The Free Software Foundation may publish new, revised versions of
   5119      the GNU Free Documentation License from time to time.  Such new
   5120      versions will be similar in spirit to the present version, but may
   5121      differ in detail to address new problems or concerns.  See
   5122      `http://www.gnu.org/copyleft/'.
   5123 
   5124      Each version of the License is given a distinguishing version
   5125      number.  If the Document specifies that a particular numbered
   5126      version of this License "or any later version" applies to it, you
   5127      have the option of following the terms and conditions either of
   5128      that specified version or of any later version that has been
   5129      published (not as a draft) by the Free Software Foundation.  If
   5130      the Document does not specify a version number of this License,
   5131      you may choose any version ever published (not as a draft) by the
   5132      Free Software Foundation.  If the Document specifies that a proxy
   5133      can decide which future versions of this License can be used, that
   5134      proxy's public statement of acceptance of a version permanently
   5135      authorizes you to choose that version for the Document.
   5136 
   5137  11. RELICENSING
   5138 
   5139      "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
   5140      World Wide Web server that publishes copyrightable works and also
   5141      provides prominent facilities for anybody to edit those works.  A
   5142      public wiki that anybody can edit is an example of such a server.
   5143      A "Massive Multiauthor Collaboration" (or "MMC") contained in the
   5144      site means any set of copyrightable works thus published on the MMC
   5145      site.
   5146 
   5147      "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
   5148      license published by Creative Commons Corporation, a not-for-profit
   5149      corporation with a principal place of business in San Francisco,
   5150      California, as well as future copyleft versions of that license
   5151      published by that same organization.
   5152 
   5153      "Incorporate" means to publish or republish a Document, in whole or
   5154      in part, as part of another Document.
   5155 
   5156      An MMC is "eligible for relicensing" if it is licensed under this
   5157      License, and if all works that were first published under this
   5158      License somewhere other than this MMC, and subsequently
   5159      incorporated in whole or in part into the MMC, (1) had no cover
   5160      texts or invariant sections, and (2) were thus incorporated prior
   5161      to November 1, 2008.
   5162 
   5163      The operator of an MMC Site may republish an MMC contained in the
   5164      site under CC-BY-SA on the same site at any time before August 1,
   5165      2009, provided the MMC is eligible for relicensing.
   5166 
   5167 
   5168 ADDENDUM: How to use this License for your documents
   5169 ====================================================
   5170 
   5171 To use this License in a document you have written, include a copy of
   5172 the License in the document and put the following copyright and license
   5173 notices just after the title page:
   5174 
   5175        Copyright (C)  YEAR  YOUR NAME.
   5176        Permission is granted to copy, distribute and/or modify this document
   5177        under the terms of the GNU Free Documentation License, Version 1.3
   5178        or any later version published by the Free Software Foundation;
   5179        with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
   5180        Texts.  A copy of the license is included in the section entitled ``GNU
   5181        Free Documentation License''.
   5182 
   5183    If you have Invariant Sections, Front-Cover Texts and Back-Cover
   5184 Texts, replace the "with...Texts." line with this:
   5185 
   5186          with the Invariant Sections being LIST THEIR TITLES, with
   5187          the Front-Cover Texts being LIST, and with the Back-Cover Texts
   5188          being LIST.
   5189 
   5190    If you have Invariant Sections without Cover Texts, or some other
   5191 combination of the three, merge those two alternatives to suit the
   5192 situation.
   5193 
   5194    If your document contains nontrivial examples of program code, we
   5195 recommend releasing these examples in parallel under your choice of
   5196 free software license, such as the GNU General Public License, to
   5197 permit their use in free software.
   5198 
   5199 
   5200 File: cpp.info,  Node: Index of Directives,  Next: Option Index,  Prev: GNU Free Documentation License,  Up: Top
   5201 
   5202 Index of Directives
   5203 *******************
   5204 
   5205 [index]
   5206 * Menu:
   5207 
   5208 * #assert:                               Obsolete Features.    (line 48)
   5209 * #define:                               Object-like Macros.   (line 11)
   5210 * #elif:                                 Elif.                 (line  6)
   5211 * #else:                                 Else.                 (line  6)
   5212 * #endif:                                Ifdef.                (line  6)
   5213 * #error:                                Diagnostics.          (line  6)
   5214 * #ident:                                Other Directives.     (line  6)
   5215 * #if:                                   Conditional Syntax.   (line  6)
   5216 * #ifdef:                                Ifdef.                (line  6)
   5217 * #ifndef:                               Ifdef.                (line 40)
   5218 * #import:                               Alternatives to Wrapper #ifndef.
   5219                                                                (line 11)
   5220 * #include:                              Include Syntax.       (line  6)
   5221 * #include_next:                         Wrapper Headers.      (line  6)
   5222 * #line:                                 Line Control.         (line 20)
   5223 * #pragma GCC dependency:                Pragmas.              (line 55)
   5224 * #pragma GCC poison:                    Pragmas.              (line 67)
   5225 * #pragma GCC system_header <1>:         Pragmas.              (line 94)
   5226 * #pragma GCC system_header:             System Headers.       (line 31)
   5227 * #sccs:                                 Other Directives.     (line  6)
   5228 * #unassert:                             Obsolete Features.    (line 59)
   5229 * #undef:                                Undefining and Redefining Macros.
   5230                                                                (line  6)
   5231 * #warning:                              Diagnostics.          (line 27)
   5232 
   5233 
   5234 File: cpp.info,  Node: Option Index,  Next: Concept Index,  Prev: Index of Directives,  Up: Top
   5235 
   5236 Option Index
   5237 ************
   5238 
   5239 CPP's command line options and environment variables are indexed here
   5240 without any initial `-' or `--'.
   5241 
   5242 [index]
   5243 * Menu:
   5244 
   5245 * A:                                     Invocation.          (line 534)
   5246 * ansi:                                  Invocation.          (line 308)
   5247 * C:                                     Invocation.          (line 593)
   5248 * C_INCLUDE_PATH:                        Environment Variables.
   5249                                                               (line  16)
   5250 * CPATH:                                 Environment Variables.
   5251                                                               (line  15)
   5252 * CPLUS_INCLUDE_PATH:                    Environment Variables.
   5253                                                               (line  17)
   5254 * D:                                     Invocation.          (line  39)
   5255 * dD:                                    Invocation.          (line 566)
   5256 * DEPENDENCIES_OUTPUT:                   Environment Variables.
   5257                                                               (line  44)
   5258 * dI:                                    Invocation.          (line 575)
   5259 * dM:                                    Invocation.          (line 550)
   5260 * dN:                                    Invocation.          (line 572)
   5261 * dU:                                    Invocation.          (line 579)
   5262 * fdirectives-only:                      Invocation.          (line 442)
   5263 * fdollars-in-identifiers:               Invocation.          (line 464)
   5264 * fexec-charset:                         Invocation.          (line 491)
   5265 * fextended-identifiers:                 Invocation.          (line 467)
   5266 * finput-charset:                        Invocation.          (line 504)
   5267 * fno-show-column:                       Invocation.          (line 529)
   5268 * fno-working-directory:                 Invocation.          (line 514)
   5269 * fpreprocessed:                         Invocation.          (line 472)
   5270 * ftabstop:                              Invocation.          (line 485)
   5271 * fwide-exec-charset:                    Invocation.          (line 496)
   5272 * fworking-directory:                    Invocation.          (line 514)
   5273 * H:                                     Invocation.          (line 638)
   5274 * help:                                  Invocation.          (line 630)
   5275 * I:                                     Invocation.          (line  71)
   5276 * I-:                                    Invocation.          (line 355)
   5277 * idirafter:                             Invocation.          (line 397)
   5278 * imacros:                               Invocation.          (line 388)
   5279 * imultilib:                             Invocation.          (line 422)
   5280 * include:                               Invocation.          (line 377)
   5281 * iprefix:                               Invocation.          (line 404)
   5282 * iquote:                                Invocation.          (line 434)
   5283 * isysroot:                              Invocation.          (line 416)
   5284 * isystem:                               Invocation.          (line 426)
   5285 * iwithprefix:                           Invocation.          (line 410)
   5286 * iwithprefixbefore:                     Invocation.          (line 410)
   5287 * M:                                     Invocation.          (line 180)
   5288 * MD:                                    Invocation.          (line 269)
   5289 * MF:                                    Invocation.          (line 215)
   5290 * MG:                                    Invocation.          (line 224)
   5291 * MM:                                    Invocation.          (line 205)
   5292 * MMD:                                   Invocation.          (line 285)
   5293 * MP:                                    Invocation.          (line 234)
   5294 * MQ:                                    Invocation.          (line 260)
   5295 * MT:                                    Invocation.          (line 246)
   5296 * nostdinc:                              Invocation.          (line 367)
   5297 * nostdinc++:                            Invocation.          (line 372)
   5298 * o:                                     Invocation.          (line  82)
   5299 * OBJC_INCLUDE_PATH:                     Environment Variables.
   5300                                                               (line  18)
   5301 * P:                                     Invocation.          (line 586)
   5302 * pedantic:                              Invocation.          (line 170)
   5303 * pedantic-errors:                       Invocation.          (line 175)
   5304 * remap:                                 Invocation.          (line 625)
   5305 * std=:                                  Invocation.          (line 308)
   5306 * SUNPRO_DEPENDENCIES:                   Environment Variables.
   5307                                                               (line  60)
   5308 * target-help:                           Invocation.          (line 630)
   5309 * traditional-cpp:                       Invocation.          (line 618)
   5310 * trigraphs:                             Invocation.          (line 622)
   5311 * U:                                     Invocation.          (line  62)
   5312 * undef:                                 Invocation.          (line  66)
   5313 * v:                                     Invocation.          (line 634)
   5314 * version:                               Invocation.          (line 647)
   5315 * w:                                     Invocation.          (line 166)
   5316 * Wall:                                  Invocation.          (line  88)
   5317 * Wcomment:                              Invocation.          (line  96)
   5318 * Wcomments:                             Invocation.          (line  96)
   5319 * Wendif-labels:                         Invocation.          (line 143)
   5320 * Werror:                                Invocation.          (line 156)
   5321 * Wsystem-headers:                       Invocation.          (line 160)
   5322 * Wtraditional:                          Invocation.          (line 113)
   5323 * Wtrigraphs:                            Invocation.          (line 101)
   5324 * Wundef:                                Invocation.          (line 119)
   5325 * Wunused-macros:                        Invocation.          (line 124)
   5326 * x:                                     Invocation.          (line 292)
   5327 
   5328 
   5329 File: cpp.info,  Node: Concept Index,  Prev: Option Index,  Up: Top
   5330 
   5331 Concept Index
   5332 *************
   5333 
   5334 [index]
   5335 * Menu:
   5336 
   5337 * # operator:                            Stringification.     (line   6)
   5338 * ## operator:                           Concatenation.       (line   6)
   5339 * _Pragma:                               Pragmas.             (line  25)
   5340 * alternative tokens:                    Tokenization.        (line 106)
   5341 * arguments:                             Macro Arguments.     (line   6)
   5342 * arguments in macro definitions:        Macro Arguments.     (line   6)
   5343 * assertions:                            Obsolete Features.   (line  13)
   5344 * assertions, canceling:                 Obsolete Features.   (line  59)
   5345 * backslash-newline:                     Initial processing.  (line  61)
   5346 * block comments:                        Initial processing.  (line  77)
   5347 * C++ named operators:                   C++ Named Operators. (line   6)
   5348 * character constants:                   Tokenization.        (line  85)
   5349 * character set, execution:              Invocation.          (line 491)
   5350 * character set, input:                  Invocation.          (line 504)
   5351 * character set, wide execution:         Invocation.          (line 496)
   5352 * command line:                          Invocation.          (line   6)
   5353 * commenting out code:                   Deleted Code.        (line   6)
   5354 * comments:                              Initial processing.  (line  77)
   5355 * common predefined macros:              Common Predefined Macros.
   5356                                                               (line   6)
   5357 * computed includes:                     Computed Includes.   (line   6)
   5358 * concatenation:                         Concatenation.       (line   6)
   5359 * conditional group:                     Ifdef.               (line  14)
   5360 * conditionals:                          Conditionals.        (line   6)
   5361 * continued lines:                       Initial processing.  (line  61)
   5362 * controlling macro:                     Once-Only Headers.   (line  35)
   5363 * defined:                               Defined.             (line   6)
   5364 * dependencies for make as output:       Environment Variables.
   5365                                                               (line  45)
   5366 * dependencies, make:                    Invocation.          (line 180)
   5367 * diagnostic:                            Diagnostics.         (line   6)
   5368 * differences from previous versions:    Differences from previous versions.
   5369                                                               (line   6)
   5370 * digraphs:                              Tokenization.        (line 106)
   5371 * directive line:                        The preprocessing language.
   5372                                                               (line   6)
   5373 * directive name:                        The preprocessing language.
   5374                                                               (line   6)
   5375 * directives:                            The preprocessing language.
   5376                                                               (line   6)
   5377 * empty macro arguments:                 Macro Arguments.     (line  66)
   5378 * environment variables:                 Environment Variables.
   5379                                                               (line   6)
   5380 * expansion of arguments:                Argument Prescan.    (line   6)
   5381 * FDL, GNU Free Documentation License:   GNU Free Documentation License.
   5382                                                               (line   6)
   5383 * function-like macros:                  Function-like Macros.
   5384                                                               (line   6)
   5385 * grouping options:                      Invocation.          (line  34)
   5386 * guard macro:                           Once-Only Headers.   (line  35)
   5387 * header file:                           Header Files.        (line   6)
   5388 * header file names:                     Tokenization.        (line  85)
   5389 * identifiers:                           Tokenization.        (line  34)
   5390 * implementation limits:                 Implementation limits.
   5391                                                               (line   6)
   5392 * implementation-defined behavior:       Implementation-defined behavior.
   5393                                                               (line   6)
   5394 * including just once:                   Once-Only Headers.   (line   6)
   5395 * invocation:                            Invocation.          (line   6)
   5396 * iso646.h:                              C++ Named Operators. (line   6)
   5397 * line comments:                         Initial processing.  (line  77)
   5398 * line control:                          Line Control.        (line   6)
   5399 * line endings:                          Initial processing.  (line  14)
   5400 * linemarkers:                           Preprocessor Output. (line  28)
   5401 * macro argument expansion:              Argument Prescan.    (line   6)
   5402 * macro arguments and directives:        Directives Within Macro Arguments.
   5403                                                               (line   6)
   5404 * macros in include:                     Computed Includes.   (line   6)
   5405 * macros with arguments:                 Macro Arguments.     (line   6)
   5406 * macros with variable arguments:        Variadic Macros.     (line   6)
   5407 * make:                                  Invocation.          (line 180)
   5408 * manifest constants:                    Object-like Macros.  (line   6)
   5409 * named operators:                       C++ Named Operators. (line   6)
   5410 * newlines in macro arguments:           Newlines in Arguments.
   5411                                                               (line   6)
   5412 * null directive:                        Other Directives.    (line  15)
   5413 * numbers:                               Tokenization.        (line  61)
   5414 * object-like macro:                     Object-like Macros.  (line   6)
   5415 * options:                               Invocation.          (line  38)
   5416 * options, grouping:                     Invocation.          (line  34)
   5417 * other tokens:                          Tokenization.        (line 120)
   5418 * output format:                         Preprocessor Output. (line  12)
   5419 * overriding a header file:              Wrapper Headers.     (line   6)
   5420 * parentheses in macro bodies:           Operator Precedence Problems.
   5421                                                               (line   6)
   5422 * pitfalls of macros:                    Macro Pitfalls.      (line   6)
   5423 * predefined macros:                     Predefined Macros.   (line   6)
   5424 * predefined macros, system-specific:    System-specific Predefined Macros.
   5425                                                               (line   6)
   5426 * predicates:                            Obsolete Features.   (line  26)
   5427 * preprocessing directives:              The preprocessing language.
   5428                                                               (line   6)
   5429 * preprocessing numbers:                 Tokenization.        (line  61)
   5430 * preprocessing tokens:                  Tokenization.        (line   6)
   5431 * prescan of macro arguments:            Argument Prescan.    (line   6)
   5432 * problems with macros:                  Macro Pitfalls.      (line   6)
   5433 * punctuators:                           Tokenization.        (line 106)
   5434 * redefining macros:                     Undefining and Redefining Macros.
   5435                                                               (line   6)
   5436 * repeated inclusion:                    Once-Only Headers.   (line   6)
   5437 * reporting errors:                      Diagnostics.         (line   6)
   5438 * reporting warnings:                    Diagnostics.         (line   6)
   5439 * reserved namespace:                    System-specific Predefined Macros.
   5440                                                               (line   6)
   5441 * self-reference:                        Self-Referential Macros.
   5442                                                               (line   6)
   5443 * semicolons (after macro calls):        Swallowing the Semicolon.
   5444                                                               (line   6)
   5445 * side effects (in macro arguments):     Duplication of Side Effects.
   5446                                                               (line   6)
   5447 * standard predefined macros.:           Standard Predefined Macros.
   5448                                                               (line   6)
   5449 * string constants:                      Tokenization.        (line  85)
   5450 * string literals:                       Tokenization.        (line  85)
   5451 * stringification:                       Stringification.     (line   6)
   5452 * symbolic constants:                    Object-like Macros.  (line   6)
   5453 * system header files <1>:               System Headers.      (line   6)
   5454 * system header files:                   Header Files.        (line  13)
   5455 * system-specific predefined macros:     System-specific Predefined Macros.
   5456                                                               (line   6)
   5457 * testing predicates:                    Obsolete Features.   (line  37)
   5458 * token concatenation:                   Concatenation.       (line   6)
   5459 * token pasting:                         Concatenation.       (line   6)
   5460 * tokens:                                Tokenization.        (line   6)
   5461 * trigraphs:                             Initial processing.  (line  32)
   5462 * undefining macros:                     Undefining and Redefining Macros.
   5463                                                               (line   6)
   5464 * unsafe macros:                         Duplication of Side Effects.
   5465                                                               (line   6)
   5466 * variable number of arguments:          Variadic Macros.     (line   6)
   5467 * variadic macros:                       Variadic Macros.     (line   6)
   5468 * wrapper #ifndef:                       Once-Only Headers.   (line   6)
   5469 * wrapper headers:                       Wrapper Headers.     (line   6)
   5470 
   5471 
   5472 
   5473 Tag Table:
   5474 Node: Top1149
   5475 Node: Overview3881
   5476 Node: Character sets6714
   5477 Ref: Character sets-Footnote-18897
   5478 Node: Initial processing9078
   5479 Ref: trigraphs10637
   5480 Node: Tokenization14839
   5481 Ref: Tokenization-Footnote-121975
   5482 Node: The preprocessing language22086
   5483 Node: Header Files24964
   5484 Node: Include Syntax26880
   5485 Node: Include Operation28517
   5486 Node: Search Path30365
   5487 Node: Once-Only Headers33555
   5488 Node: Alternatives to Wrapper #ifndef35214
   5489 Node: Computed Includes36957
   5490 Node: Wrapper Headers40115
   5491 Node: System Headers42541
   5492 Node: Macros44591
   5493 Node: Object-like Macros45732
   5494 Node: Function-like Macros49322
   5495 Node: Macro Arguments50938
   5496 Node: Stringification55083
   5497 Node: Concatenation58289
   5498 Node: Variadic Macros61397
   5499 Node: Predefined Macros66184
   5500 Node: Standard Predefined Macros66772
   5501 Node: Common Predefined Macros72709
   5502 Node: System-specific Predefined Macros90212
   5503 Node: C++ Named Operators92233
   5504 Node: Undefining and Redefining Macros93197
   5505 Node: Directives Within Macro Arguments95301
   5506 Node: Macro Pitfalls96849
   5507 Node: Misnesting97382
   5508 Node: Operator Precedence Problems98494
   5509 Node: Swallowing the Semicolon100360
   5510 Node: Duplication of Side Effects102383
   5511 Node: Self-Referential Macros104566
   5512 Node: Argument Prescan106975
   5513 Node: Newlines in Arguments110729
   5514 Node: Conditionals111680
   5515 Node: Conditional Uses113510
   5516 Node: Conditional Syntax114868
   5517 Node: Ifdef115188
   5518 Node: If118349
   5519 Node: Defined120653
   5520 Node: Else121936
   5521 Node: Elif122506
   5522 Node: Deleted Code123795
   5523 Node: Diagnostics125042
   5524 Node: Line Control126659
   5525 Node: Pragmas130463
   5526 Node: Other Directives134780
   5527 Node: Preprocessor Output135830
   5528 Node: Traditional Mode139031
   5529 Node: Traditional lexical analysis140089
   5530 Node: Traditional macros142592
   5531 Node: Traditional miscellany146394
   5532 Node: Traditional warnings147391
   5533 Node: Implementation Details149588
   5534 Node: Implementation-defined behavior150209
   5535 Ref: Identifier characters150961
   5536 Node: Implementation limits154039
   5537 Node: Obsolete Features156713
   5538 Node: Differences from previous versions159601
   5539 Node: Invocation163809
   5540 Ref: Wtrigraphs168261
   5541 Ref: dashMF173036
   5542 Ref: fdollars-in-identifiers182747
   5543 Node: Environment Variables190910
   5544 Node: GNU Free Documentation License193876
   5545 Node: Index of Directives219040
   5546 Node: Option Index220974
   5547 Node: Concept Index227158
   5548 
   5549 End Tag Table
   5550