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