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