1 This is doc/cpp.info, produced by makeinfo version 4.2 from
2 ../../gcc/gcc/doc/cpp.texi.
4 Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
5 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
7 Permission is granted to copy, distribute and/or modify this document
8 under the terms of the GNU Free Documentation License, Version 1.1 or
9 any later version published by the Free Software Foundation. A copy of
10 the license is included in the section entitled "GNU Free Documentation
13 This manual contains no Invariant Sections. The Front-Cover Texts
14 are (a) (see below), and the Back-Cover Texts are (b) (see below).
16 (a) The FSF's Front-Cover Text is:
20 (b) The FSF's Back-Cover Text is:
22 You have freedom to copy and modify this GNU Manual, like GNU
23 software. Copies published by the Free Software Foundation raise
24 funds for GNU development.
25 INFO-DIR-SECTION Programming
27 * Cpp: (cpp). The GNU C preprocessor.
31 File: cpp.info, Node: Top, Next: Overview, Up: (dir)
35 The C preprocessor implements the macro language used to transform C,
36 C++, and Objective-C programs before they are compiled. It can also be
49 * Preprocessor Output::
51 * Implementation Details::
53 * Environment Variables::
54 * GNU Free Documentation License::
55 * Index of Directives::
59 --- The Detailed Node Listing ---
64 * Initial processing::
66 * The preprocessing language::
80 * Object-like Macros::
81 * Function-like Macros::
87 * Undefining and Redefining Macros::
88 * Directives Within Macro Arguments::
93 * Standard Predefined Macros::
94 * Common Predefined Macros::
95 * System-specific Predefined Macros::
96 * C++ Named Operators::
101 * Operator Precedence Problems::
102 * Swallowing the Semicolon::
103 * Duplication of Side Effects::
104 * Self-Referential Macros::
106 * Newlines in Arguments::
111 * Conditional Syntax::
122 Implementation Details
124 * Implementation-defined behavior::
125 * Implementation limits::
126 * Obsolete Features::
127 * Differences from previous versions::
132 * Obsolete once-only headers::
134 Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
135 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
137 Permission is granted to copy, distribute and/or modify this document
138 under the terms of the GNU Free Documentation License, Version 1.1 or
139 any later version published by the Free Software Foundation. A copy of
140 the license is included in the section entitled "GNU Free Documentation
143 This manual contains no Invariant Sections. The Front-Cover Texts
144 are (a) (see below), and the Back-Cover Texts are (b) (see below).
146 (a) The FSF's Front-Cover Text is:
150 (b) The FSF's Back-Cover Text is:
152 You have freedom to copy and modify this GNU Manual, like GNU
153 software. Copies published by the Free Software Foundation raise
154 funds for GNU development.
156 File: cpp.info, Node: Overview, Next: Header Files, Prev: Top, Up: Top
161 The C preprocessor, often known as "cpp", is a "macro processor"
162 that is used automatically by the C compiler to transform your program
163 before compilation. It is called a macro processor because it allows
164 you to define "macros", which are brief abbreviations for longer
167 The C preprocessor is intended to be used only with C, C++, and
168 Objective-C source code. In the past, it has been abused as a general
169 text processor. It will choke on input which does not obey C's lexical
170 rules. For example, apostrophes will be interpreted as the beginning of
171 character constants, and cause errors. Also, you cannot rely on it
172 preserving characteristics of the input which are not significant to
173 C-family languages. If a Makefile is preprocessed, all the hard tabs
174 will be removed, and the Makefile will not work.
176 Having said that, you can often get away with using cpp on things
177 which are not C. Other Algol-ish programming languages are often safe
178 (Pascal, Ada, etc.) So is assembly, with caution. `-traditional-cpp'
179 mode preserves more white space, and is otherwise more permissive. Many
180 of the problems can be avoided by writing C or C++ style comments
181 instead of native language comments, and keeping macros simple.
183 Wherever possible, you should use a preprocessor geared to the
184 language you are writing in. Modern versions of the GNU assembler have
185 macro facilities. Most high level programming languages have their own
186 conditional compilation and inclusion mechanism. If all else fails,
187 try a true general text processor, such as GNU M4.
189 C preprocessors vary in some details. This manual discusses the GNU
190 C preprocessor, which provides a small superset of the features of ISO
191 Standard C. In its default mode, the GNU C preprocessor does not do a
192 few things required by the standard. These are features which are
193 rarely, if ever, used, and may cause surprising changes to the meaning
194 of a program which does not expect them. To get strict ISO Standard C,
195 you should use the `-std=c89' or `-std=c99' options, depending on which
196 version of the standard you want. To get all the mandatory
197 diagnostics, you must also use `-pedantic'. *Note Invocation::.
199 This manual describes the behavior of the ISO preprocessor. To
200 minimize gratuitous differences, where the ISO preprocessor's behavior
201 does not conflict with traditional semantics, the traditional
202 preprocessor should behave the same way. The various differences that
203 do exist are detailed in the section *Note Traditional Mode::.
205 For clarity, unless noted otherwise, references to `CPP' in this
206 manual refer to GNU CPP.
211 * Initial processing::
213 * The preprocessing language::
216 File: cpp.info, Node: Character sets, Next: Initial processing, Up: Overview
221 Source code character set processing in C and related languages is
222 rather complicated. The C standard discusses two character sets, but
223 there are really at least four.
225 The files input to CPP might be in any character set at all. CPP's
226 very first action, before it even looks for line boundaries, is to
227 convert the file into the character set it uses for internal
228 processing. That set is what the C standard calls the "source"
229 character set. It must be isomorphic with ISO 10646, also known as
230 Unicode. CPP uses the UTF-8 encoding of Unicode.
232 At present, GNU CPP does not implement conversion from arbitrary file
233 encodings to the source character set. Use of any encoding other than
234 plain ASCII or UTF-8, except in comments, will cause errors. Use of
235 encodings that are not strict supersets of ASCII, such as Shift JIS,
236 may cause errors even if non-ASCII characters appear only in comments.
237 We plan to fix this in the near future.
239 All preprocessing work (the subject of the rest of this manual) is
240 carried out in the source character set. If you request textual output
241 from the preprocessor with the `-E' option, it will be in UTF-8.
243 After preprocessing is complete, string and character constants are
244 converted again, into the "execution" character set. This character
245 set is under control of the user; the default is UTF-8, matching the
246 source character set. Wide string and character constants have their
247 own character set, which is not called out specifically in the
248 standard. Again, it is under control of the user. The default is
249 UTF-16 or UTF-32, whichever fits in the target's `wchar_t' type, in the
250 target machine's byte order.(1) Octal and hexadecimal escape sequences
251 do not undergo conversion; '\x12' has the value 0x12 regardless of the
252 currently selected execution character set. All other escapes are
253 replaced by the character in the source character set that they
254 represent, then converted to the execution character set, just like
255 unescaped characters.
257 GCC does not permit the use of characters outside the ASCII range,
258 nor `\u' and `\U' escapes, in identifiers. We hope this will change
259 eventually, but there are problems with the standard semantics of such
260 "extended identifiers" which must be resolved through the ISO C and C++
263 ---------- Footnotes ----------
265 (1) UTF-16 does not meet the requirements of the C standard for a
266 wide character set, but the choice of 16-bit `wchar_t' is enshrined in
267 some system ABIs so we cannot fix this.
270 File: cpp.info, Node: Initial processing, Next: Tokenization, Prev: Character sets, Up: Overview
275 The preprocessor performs a series of textual transformations on its
276 input. These happen before all other processing. Conceptually, they
277 happen in a rigid order, and the entire file is run through each
278 transformation before the next one begins. CPP actually does them all
279 at once, for performance reasons. These transformations correspond
280 roughly to the first three "phases of translation" described in the C
283 1. The input file is read into memory and broken into lines.
285 Different systems use different conventions to indicate the end of
286 a line. GCC accepts the ASCII control sequences `LF', `CR LF' and
287 `CR' as end-of-line markers. These are the canonical sequences
288 used by Unix, DOS and VMS, and the classic Mac OS (before OSX)
289 respectively. You may therefore safely copy source code written
290 on any of those systems to a different one and use it without
291 conversion. (GCC may lose track of the current line number if a
292 file doesn't consistently use one convention, as sometimes happens
293 when it is edited on computers with different conventions that
294 share a network file system.)
296 If the last line of any input file lacks an end-of-line marker,
297 the end of the file is considered to implicitly supply one. The C
298 standard says that this condition provokes undefined behavior, so
299 GCC will emit a warning message.
301 2. If trigraphs are enabled, they are replaced by their corresponding
302 single characters. By default GCC ignores trigraphs, but if you
303 request a strictly conforming mode with the `-std' option, or you
304 specify the `-trigraphs' option, then it converts them.
306 These are nine three-character sequences, all starting with `??',
307 that are defined by ISO C to stand for single characters. They
308 permit obsolete systems that lack some of C's punctuation to use
309 C. For example, `??/' stands for `\', so '??/n' is a character
310 constant for a newline.
312 Trigraphs are not popular and many compilers implement them
313 incorrectly. Portable code should not rely on trigraphs being
314 either converted or ignored. With `-Wtrigraphs' GCC will warn you
315 when a trigraph may change the meaning of your program if it were
316 converted. *Note Wtrigraphs::.
318 In a string constant, you can prevent a sequence of question marks
319 from being confused with a trigraph by inserting a backslash
320 between the question marks, or by separating the string literal at
321 the trigraph and making use of string literal concatenation.
322 "(??\?)" is the string `(???)', not `(?]'. Traditional C
323 compilers do not recognize these idioms.
325 The nine trigraphs and their replacements are
327 Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??-
328 Replacement: [ ] { } # \ ^ | ~
330 3. Continued lines are merged into one long line.
332 A continued line is a line which ends with a backslash, `\'. The
333 backslash is removed and the following line is joined with the
334 current one. No space is inserted, so you may split a line
335 anywhere, even in the middle of a word. (It is generally more
336 readable to split lines only at white space.)
338 The trailing backslash on a continued line is commonly referred to
339 as a "backslash-newline".
341 If there is white space between a backslash and the end of a line,
342 that is still a continued line. However, as this is usually the
343 result of an editing mistake, and many compilers will not accept
344 it as a continued line, GCC will warn you about it.
346 4. All comments are replaced with single spaces.
348 There are two kinds of comments. "Block comments" begin with `/*'
349 and continue until the next `*/'. Block comments do not nest:
351 /* this is /* one comment */ text outside comment
353 "Line comments" begin with `//' and continue to the end of the
354 current line. Line comments do not nest either, but it does not
355 matter, because they would end in the same place anyway.
357 // this is // one comment
360 It is safe to put line comments inside block comments, or vice versa.
363 // contains line comment
367 // line comment /* contains block comment */
369 But beware of commenting out one end of a block comment with a line
372 // l.c. /* block comment begins
373 oops! this isn't a comment anymore */
375 Comments are not recognized within string literals. "/* blah */" is
376 the string constant `/* blah */', not an empty string.
378 Line comments are not in the 1989 edition of the C standard, but they
379 are recognized by GCC as an extension. In C++ and in the 1999 edition
380 of the C standard, they are an official part of the language.
382 Since these transformations happen before all other processing, you
383 can split a line mechanically with backslash-newline anywhere. You can
384 comment out the end of a line. You can continue a line comment onto the
385 next line with backslash-newline. You can even split `/*', `*/', and
386 `//' onto multiple lines with backslash-newline. For example:
396 is equivalent to `#define FOO 1020'. All these tricks are extremely
397 confusing and should not be used in code intended to be readable.
399 There is no way to prevent a backslash at the end of a line from
400 being interpreted as a backslash-newline. This cannot affect any
401 correct program, however.
404 File: cpp.info, Node: Tokenization, Next: The preprocessing language, Prev: Initial processing, Up: Overview
409 After the textual transformations are finished, the input file is
410 converted into a sequence of "preprocessing tokens". These mostly
411 correspond to the syntactic tokens used by the C compiler, but there are
412 a few differences. White space separates tokens; it is not itself a
413 token of any kind. Tokens do not have to be separated by white space,
414 but it is often necessary to avoid ambiguities.
416 When faced with a sequence of characters that has more than one
417 possible tokenization, the preprocessor is greedy. It always makes
418 each token, starting from the left, as big as possible before moving on
419 to the next token. For instance, `a+++++b' is interpreted as
420 `a ++ ++ + b', not as `a ++ + ++ b', even though the latter
421 tokenization could be part of a valid C program and the former could
424 Once the input file is broken into tokens, the token boundaries never
425 change, except when the `##' preprocessing operator is used to paste
426 tokens together. *Note Concatenation::. For example,
434 The compiler does not re-tokenize the preprocessor's output. Each
435 preprocessing token becomes one compiler token.
437 Preprocessing tokens fall into five broad classes: identifiers,
438 preprocessing numbers, string literals, punctuators, and other. An
439 "identifier" is the same as an identifier in C: any sequence of
440 letters, digits, or underscores, which begins with a letter or
441 underscore. Keywords of C have no significance to the preprocessor;
442 they are ordinary identifiers. You can define a macro whose name is a
443 keyword, for instance. The only identifier which can be considered a
444 preprocessing keyword is `defined'. *Note Defined::.
446 This is mostly true of other languages which use the C preprocessor.
447 However, a few of the keywords of C++ are significant even in the
448 preprocessor. *Note C++ Named Operators::.
450 In the 1999 C standard, identifiers may contain letters which are not
451 part of the "basic source character set," at the implementation's
452 discretion (such as accented Latin letters, Greek letters, or Chinese
453 ideograms). This may be done with an extended character set, or the
454 `\u' and `\U' escape sequences. GCC does not presently implement
455 either feature in the preprocessor or the compiler.
457 As an extension, GCC treats `$' as a letter. This is for
458 compatibility with some systems, such as VMS, where `$' is commonly
459 used in system-defined function and object names. `$' is not a letter
460 in strictly conforming mode, or if you specify the `-$' option. *Note
463 A "preprocessing number" has a rather bizarre definition. The
464 category includes all the normal integer and floating point constants
465 one expects of C, but also a number of other things one might not
466 initially recognize as a number. Formally, preprocessing numbers begin
467 with an optional period, a required decimal digit, and then continue
468 with any sequence of letters, digits, underscores, periods, and
469 exponents. Exponents are the two-character sequences `e+', `e-', `E+',
470 `E-', `p+', `p-', `P+', and `P-'. (The exponents that begin with `p'
471 or `P' are new to C99. They are used for hexadecimal floating-point
474 The purpose of this unusual definition is to isolate the preprocessor
475 from the full complexity of numeric constants. It does not have to
476 distinguish between lexically valid and invalid floating-point numbers,
477 which is complicated. The definition also permits you to split an
478 identifier at any position and get exactly two tokens, which can then be
479 pasted back together with the `##' operator.
481 It's possible for preprocessing numbers to cause programs to be
482 misinterpreted. For example, `0xE+12' is a preprocessing number which
483 does not translate to any valid numeric constant, therefore a syntax
484 error. It does not mean `0xE + 12', which is what you might have
487 "String literals" are string constants, character constants, and
488 header file names (the argument of `#include').(1) String constants
489 and character constants are straightforward: "..." or '...'. In either
490 case embedded quotes should be escaped with a backslash: '\'' is the
491 character constant for `''. There is no limit on the length of a
492 character constant, but the value of a character constant that contains
493 more than one character is implementation-defined. *Note
494 Implementation Details::.
496 Header file names either look like string constants, "...", or are
497 written with angle brackets instead, <...>. In either case, backslash
498 is an ordinary character. There is no way to escape the closing quote
499 or angle bracket. The preprocessor looks for the header file in
500 different places depending on which form you use. *Note Include
503 No string literal may extend past the end of a line. Older versions
504 of GCC accepted multi-line string constants. You may use continued
505 lines instead, or string constant concatenation. *Note Differences
506 from previous versions::.
508 "Punctuators" are all the usual bits of punctuation which are
509 meaningful to C and C++. All but three of the punctuation characters in
510 ASCII are C punctuators. The exceptions are `@', `$', and ``'. In
511 addition, all the two- and three-character operators are punctuators.
512 There are also six "digraphs", which the C++ standard calls
513 "alternative tokens", which are merely alternate ways to spell other
514 punctuators. This is a second attempt to work around missing
515 punctuation in obsolete systems. It has no negative side effects,
516 unlike trigraphs, but does not cover as much ground. The digraphs and
517 their corresponding normal punctuators are:
519 Digraph: <% %> <: :> %: %:%:
520 Punctuator: { } [ ] # ##
522 Any other single character is considered "other." It is passed on to
523 the preprocessor's output unmolested. The C compiler will almost
524 certainly reject source code containing "other" tokens. In ASCII, the
525 only other characters are `@', `$', ``', and control characters other
526 than NUL (all bits zero). (Note that `$' is normally considered a
527 letter.) All characters with the high bit set (numeric range
528 0x7F-0xFF) are also "other" in the present implementation. This will
529 change when proper support for international character sets is added to
532 NUL is a special case because of the high probability that its
533 appearance is accidental, and because it may be invisible to the user
534 (many terminals do not display NUL at all). Within comments, NULs are
535 silently ignored, just as any other character would be. In running
536 text, NUL is considered white space. For example, these two directives
537 have the same meaning.
542 (where `^@' is ASCII NUL). Within string or character constants, NULs
543 are preserved. In the latter two cases the preprocessor emits a
546 ---------- Footnotes ----------
548 (1) The C standard uses the term "string literal" to refer only to
549 what we are calling "string constants".
552 File: cpp.info, Node: The preprocessing language, Prev: Tokenization, Up: Overview
554 The preprocessing language
555 ==========================
557 After tokenization, the stream of tokens may simply be passed
558 straight to the compiler's parser. However, if it contains any
559 operations in the "preprocessing language", it will be transformed
560 first. This stage corresponds roughly to the standard's "translation
561 phase 4" and is what most people think of as the preprocessor's job.
563 The preprocessing language consists of "directives" to be executed
564 and "macros" to be expanded. Its primary capabilities are:
566 * Inclusion of header files. These are files of declarations that
567 can be substituted into your program.
569 * Macro expansion. You can define "macros", which are abbreviations
570 for arbitrary fragments of C code. The preprocessor will replace
571 the macros with their definitions throughout the program. Some
572 macros are automatically defined for you.
574 * Conditional compilation. You can include or exclude parts of the
575 program according to various conditions.
577 * Line control. If you use a program to combine or rearrange source
578 files into an intermediate file which is then compiled, you can
579 use line control to inform the compiler where each source line
580 originally came from.
582 * Diagnostics. You can detect problems at compile time and issue
585 There are a few more, less useful, features.
587 Except for expansion of predefined macros, all these operations are
588 triggered with "preprocessing directives". Preprocessing directives
589 are lines in your program that start with `#'. Whitespace is allowed
590 before and after the `#'. The `#' is followed by an identifier, the
591 "directive name". It specifies the operation to perform. Directives
592 are commonly referred to as `#NAME' where NAME is the directive name.
593 For example, `#define' is the directive that defines a macro.
595 The `#' which begins a directive cannot come from a macro expansion.
596 Also, the directive name is not macro expanded. Thus, if `foo' is
597 defined as a macro expanding to `define', that does not make `#foo' a
598 valid preprocessing directive.
600 The set of valid directive names is fixed. Programs cannot define
601 new preprocessing directives.
603 Some directives require arguments; these make up the rest of the
604 directive line and must be separated from the directive name by
605 whitespace. For example, `#define' must be followed by a macro name
606 and the intended expansion of the macro.
608 A preprocessing directive cannot cover more than one line. The line
609 may, however, be continued with backslash-newline, or by a block comment
610 which extends past the end of the line. In either case, when the
611 directive is processed, the continuations have already been merged with
612 the first line to make one long line.
615 File: cpp.info, Node: Header Files, Next: Macros, Prev: Overview, Up: Top
620 A header file is a file containing C declarations and macro
621 definitions (*note Macros::) to be shared between several source files.
622 You request the use of a header file in your program by "including"
623 it, with the C preprocessing directive `#include'.
625 Header files serve two purposes.
627 * System header files declare the interfaces to parts of the
628 operating system. You include them in your program to supply the
629 definitions and declarations you need to invoke system calls and
632 * Your own header files contain declarations for interfaces between
633 the source files of your program. Each time you have a group of
634 related declarations and macro definitions all or most of which
635 are needed in several different source files, it is a good idea to
636 create a header file for them.
638 Including a header file produces the same results as copying the
639 header file into each source file that needs it. Such copying would be
640 time-consuming and error-prone. With a header file, the related
641 declarations appear in only one place. If they need to be changed, they
642 can be changed in one place, and programs that include the header file
643 will automatically use the new version when next recompiled. The header
644 file eliminates the labor of finding and changing all the copies as well
645 as the risk that a failure to find one copy will result in
646 inconsistencies within a program.
648 In C, the usual convention is to give header files names that end
649 with `.h'. It is most portable to use only letters, digits, dashes, and
650 underscores in header file names, and at most one dot.
655 * Include Operation::
657 * Once-Only Headers::
658 * Computed Includes::
663 File: cpp.info, Node: Include Syntax, Next: Include Operation, Up: Header Files
668 Both user and system header files are included using the
669 preprocessing directive `#include'. It has two variants:
672 This variant is used for system header files. It searches for a
673 file named FILE in a standard list of system directories. You can
674 prepend directories to this list with the `-I' option (*note
678 This variant is used for header files of your own program. It
679 searches for a file named FILE first in the directory containing
680 the current file, then in the same directories used for `<FILE>'.
682 The argument of `#include', whether delimited with quote marks or
683 angle brackets, behaves like a string constant in that comments are not
684 recognized, and macro names are not expanded. Thus, `#include <x/*y>'
685 specifies inclusion of a system header file named `x/*y'.
687 However, if backslashes occur within FILE, they are considered
688 ordinary text characters, not escape characters. None of the character
689 escape sequences appropriate to string constants in C are processed.
690 Thus, `#include "x\n\\y"' specifies a filename containing three
691 backslashes. (Some systems interpret `\' as a pathname separator. All
692 of these also interpret `/' the same way. It is most portable to use
695 It is an error if there is anything (other than comments) on the line
699 File: cpp.info, Node: Include Operation, Next: Search Path, Prev: Include Syntax, Up: Header Files
704 The `#include' directive works by directing the C preprocessor to
705 scan the specified file as input before continuing with the rest of the
706 current file. The output from the preprocessor contains the output
707 already generated, followed by the output resulting from the included
708 file, followed by the output that comes from the text after the
709 `#include' directive. For example, if you have a header file
710 `header.h' as follows,
714 and a main program called `program.c' that uses the header file, like
726 the compiler will see the same token stream as it would if `program.c'
738 Included files are not limited to declarations and macro definitions;
739 those are merely the typical uses. Any fragment of a C program can be
740 included from another file. The include file could even contain the
741 beginning of a statement that is concluded in the containing file, or
742 the end of a statement that was started in the including file. However,
743 an included file must consist of complete tokens. Comments and string
744 literals which have not been closed by the end of an included file are
745 invalid. For error recovery, they are considered to end at the end of
748 To avoid confusion, it is best if header files contain only complete
749 syntactic units--function declarations or definitions, type
752 The line following the `#include' directive is always treated as a
753 separate line by the C preprocessor, even if the included file lacks a
757 File: cpp.info, Node: Search Path, Next: Once-Only Headers, Prev: Include Operation, Up: Header Files
762 GCC looks in several different places for headers. On a normal Unix
763 system, if you do not instruct it otherwise, it will look for headers
764 requested with `#include <FILE>' in:
767 LIBDIR/gcc/TARGET/VERSION/include
771 For C++ programs, it will also look in `/usr/include/g++-v3', first.
772 In the above, TARGET is the canonical name of the system GCC was
773 configured to compile code for; often but not always the same as the
774 canonical name of the system it runs on. VERSION is the version of GCC
777 You can add to this list with the `-IDIR' command line option. All
778 the directories named by `-I' are searched, in left-to-right order,
779 _before_ the default directories. The only exception is when `dir' is
780 already searched by default. In this case, the option is ignored and
781 the search order for system directories remains unchanged.
783 Duplicate directories are removed from the quote and bracket search
784 chains before the two chains are merged to make the final search chain.
785 Thus, it is possible for a directory to occur twice in the final search
786 chain if it was specified in both the quote and bracket chains.
788 You can prevent GCC from searching any of the default directories
789 with the `-nostdinc' option. This is useful when you are compiling an
790 operating system kernel or some other program that does not use the
791 standard C library facilities, or the standard C library itself. `-I'
792 options are not ignored as described above when `-nostdinc' is in
795 GCC looks for headers requested with `#include "FILE"' first in the
796 directory containing the current file, then in the same places it would
797 have looked for a header requested with angle brackets. For example,
798 if `/usr/include/sys/stat.h' contains `#include "types.h"', GCC looks
799 for `types.h' first in `/usr/include/sys', then in its usual search
802 `#line' (*note Line Control::) does not change GCC's idea of the
803 directory containing the current file.
805 You may put `-I-' at any point in your list of `-I' options. This
806 has two effects. First, directories appearing before the `-I-' in the
807 list are searched only for headers requested with quote marks.
808 Directories after `-I-' are searched for all headers. Second, the
809 directory containing the current file is not searched for anything,
810 unless it happens to be one of the directories named by an `-I' switch.
812 `-I. -I-' is not the same as no `-I' options at all, and does not
813 cause the same behavior for `<>' includes that `""' includes get with
814 no special options. `-I.' searches the compiler's current working
815 directory for header files. That may or may not be the same as the
816 directory containing the current file.
818 If you need to look for headers in a directory named `-', write
821 There are several more ways to adjust the header search path. They
822 are generally less useful. *Note Invocation::.
825 File: cpp.info, Node: Once-Only Headers, Next: Computed Includes, Prev: Search Path, Up: Header Files
830 If a header file happens to be included twice, the compiler will
831 process its contents twice. This is very likely to cause an error,
832 e.g. when the compiler sees the same structure definition twice. Even
833 if it does not, it will certainly waste time.
835 The standard way to prevent this is to enclose the entire real
836 contents of the file in a conditional, like this:
839 #ifndef FILE_FOO_SEEN
840 #define FILE_FOO_SEEN
844 #endif /* !FILE_FOO_SEEN */
846 This construct is commonly known as a "wrapper #ifndef". When the
847 header is included again, the conditional will be false, because
848 `FILE_FOO_SEEN' is defined. The preprocessor will skip over the entire
849 contents of the file, and the compiler will not see it twice.
851 CPP optimizes even further. It remembers when a header file has a
852 wrapper `#ifndef'. If a subsequent `#include' specifies that header,
853 and the macro in the `#ifndef' is still defined, it does not bother to
854 rescan the file at all.
856 You can put comments outside the wrapper. They will not interfere
857 with this optimization.
859 The macro `FILE_FOO_SEEN' is called the "controlling macro" or
860 "guard macro". In a user header file, the macro name should not begin
861 with `_'. In a system header file, it should begin with `__' to avoid
862 conflicts with user programs. In any kind of header file, the macro
863 name should contain the name of the file and some additional text, to
864 avoid conflicts with other header files.
867 File: cpp.info, Node: Computed Includes, Next: Wrapper Headers, Prev: Once-Only Headers, Up: Header Files
872 Sometimes it is necessary to select one of several different header
873 files to be included into your program. They might specify
874 configuration parameters to be used on different sorts of operating
875 systems, for instance. You could do this with a series of conditionals,
878 # include "system_1.h"
880 # include "system_2.h"
885 That rapidly becomes tedious. Instead, the preprocessor offers the
886 ability to use a macro for the header name. This is called a "computed
887 include". Instead of writing a header name as the direct argument of
888 `#include', you simply put a macro name there instead:
890 #define SYSTEM_H "system_1.h"
894 `SYSTEM_H' will be expanded, and the preprocessor will look for
895 `system_1.h' as if the `#include' had been written that way originally.
896 `SYSTEM_H' could be defined by your Makefile with a `-D' option.
898 You must be careful when you define the macro. `#define' saves
899 tokens, not text. The preprocessor has no way of knowing that the macro
900 will be used as the argument of `#include', so it generates ordinary
901 tokens, not a header name. This is unlikely to cause problems if you
902 use double-quote includes, which are close enough to string constants.
903 If you use angle brackets, however, you may have trouble.
905 The syntax of a computed include is actually a bit more general than
906 the above. If the first non-whitespace character after `#include' is
907 not `"' or `<', then the entire line is macro-expanded like running
910 If the line expands to a single string constant, the contents of that
911 string constant are the file to be included. CPP does not re-examine
912 the string for embedded quotes, but neither does it process backslash
913 escapes in the string. Therefore
915 #define HEADER "a\"b"
918 looks for a file named `a\"b'. CPP searches for the file according to
919 the rules for double-quoted includes.
921 If the line expands to a token stream beginning with a `<' token and
922 including a `>' token, then the tokens between the `<' and the first
923 `>' are combined to form the filename to be included. Any whitespace
924 between tokens is reduced to a single space; then any space after the
925 initial `<' is retained, but a trailing space before the closing `>' is
926 ignored. CPP searches for the file according to the rules for
927 angle-bracket includes.
929 In either case, if there are any tokens on the line after the file
930 name, an error occurs and the directive is not processed. It is also
931 an error if the result of expansion does not match either of the two
934 These rules are implementation-defined behavior according to the C
935 standard. To minimize the risk of different compilers interpreting your
936 computed includes differently, we recommend you use only a single
937 object-like macro which expands to a string constant. This will also
938 minimize confusion for people reading your program.
941 File: cpp.info, Node: Wrapper Headers, Next: System Headers, Prev: Computed Includes, Up: Header Files
946 Sometimes it is necessary to adjust the contents of a system-provided
947 header file without editing it directly. GCC's `fixincludes' operation
948 does this, for example. One way to do that would be to create a new
949 header file with the same name and insert it in the search path before
950 the original header. That works fine as long as you're willing to
951 replace the old header entirely. But what if you want to refer to the
952 old header from the new one?
954 You cannot simply include the old header with `#include'. That will
955 start from the beginning, and find your new header again. If your
956 header is not protected from multiple inclusion (*note Once-Only
957 Headers::), it will recurse infinitely and cause a fatal error.
959 You could include the old header with an absolute pathname:
960 #include "/usr/include/old-header.h"
962 This works, but is not clean; should the system headers ever move, you
963 would have to edit the new headers to match.
965 There is no way to solve this problem within the C standard, but you
966 can use the GNU extension `#include_next'. It means, "Include the
967 _next_ file with this name." This directive works like `#include'
968 except in searching for the specified file: it starts searching the
969 list of header file directories _after_ the directory in which the
970 current file was found.
972 Suppose you specify `-I /usr/local/include', and the list of
973 directories to search also includes `/usr/include'; and suppose both
974 directories contain `signal.h'. Ordinary `#include <signal.h>' finds
975 the file under `/usr/local/include'. If that file contains
976 `#include_next <signal.h>', it starts searching after that directory,
977 and finds the file in `/usr/include'.
979 `#include_next' does not distinguish between `<FILE>' and `"FILE"'
980 inclusion, nor does it check that the file you specify has the same
981 name as the current file. It simply looks for the file named, starting
982 with the directory in the search path after the one where the current
985 The use of `#include_next' can lead to great confusion. We
986 recommend it be used only when there is no other alternative. In
987 particular, it should not be used in the headers belonging to a specific
988 program; it should be used only to make global corrections along the
989 lines of `fixincludes'.
992 File: cpp.info, Node: System Headers, Prev: Wrapper Headers, Up: Header Files
997 The header files declaring interfaces to the operating system and
998 runtime libraries often cannot be written in strictly conforming C.
999 Therefore, GCC gives code found in "system headers" special treatment.
1000 All warnings, other than those generated by `#warning' (*note
1001 Diagnostics::), are suppressed while GCC is processing a system header.
1002 Macros defined in a system header are immune to a few warnings
1003 wherever they are expanded. This immunity is granted on an ad-hoc
1004 basis, when we find that a warning generates lots of false positives
1005 because of code in macros defined in system headers.
1007 Normally, only the headers found in specific directories are
1008 considered system headers. These directories are determined when GCC
1009 is compiled. There are, however, two ways to make normal headers into
1012 The `-isystem' command line option adds its argument to the list of
1013 directories to search for headers, just like `-I'. Any headers found
1014 in that directory will be considered system headers.
1016 All directories named by `-isystem' are searched _after_ all
1017 directories named by `-I', no matter what their order was on the
1018 command line. If the same directory is named by both `-I' and
1019 `-isystem', the `-I' option is ignored. GCC provides an informative
1020 message when this occurs if `-v' is used.
1022 There is also a directive, `#pragma GCC system_header', which tells
1023 GCC to consider the rest of the current include file a system header,
1024 no matter where it was found. Code that comes before the `#pragma' in
1025 the file will not be affected. `#pragma GCC system_header' has no
1026 effect in the primary source file.
1028 On very old systems, some of the pre-defined system header
1029 directories get even more special treatment. GNU C++ considers code in
1030 headers found in those directories to be surrounded by an `extern "C"'
1031 block. There is no way to request this behavior with a `#pragma', or
1032 from the command line.
1035 File: cpp.info, Node: Macros, Next: Conditionals, Prev: Header Files, Up: Top
1040 A "macro" is a fragment of code which has been given a name.
1041 Whenever the name is used, it is replaced by the contents of the macro.
1042 There are two kinds of macros. They differ mostly in what they look
1043 like when they are used. "Object-like" macros resemble data objects
1044 when used, "function-like" macros resemble function calls.
1046 You may define any valid identifier as a macro, even if it is a C
1047 keyword. The preprocessor does not know anything about keywords. This
1048 can be useful if you wish to hide a keyword such as `const' from an
1049 older compiler that does not understand it. However, the preprocessor
1050 operator `defined' (*note Defined::) can never be defined as a macro,
1051 and C++'s named operators (*note C++ Named Operators::) cannot be
1052 macros when you are compiling C++.
1056 * Object-like Macros::
1057 * Function-like Macros::
1062 * Predefined Macros::
1063 * Undefining and Redefining Macros::
1064 * Directives Within Macro Arguments::
1068 File: cpp.info, Node: Object-like Macros, Next: Function-like Macros, Up: Macros
1073 An "object-like macro" is a simple identifier which will be replaced
1074 by a code fragment. It is called object-like because it looks like a
1075 data object in code that uses it. They are most commonly used to give
1076 symbolic names to numeric constants.
1078 You create macros with the `#define' directive. `#define' is
1079 followed by the name of the macro and then the token sequence it should
1080 be an abbreviation for, which is variously referred to as the macro's
1081 "body", "expansion" or "replacement list". For example,
1083 #define BUFFER_SIZE 1024
1085 defines a macro named `BUFFER_SIZE' as an abbreviation for the token
1086 `1024'. If somewhere after this `#define' directive there comes a C
1087 statement of the form
1089 foo = (char *) malloc (BUFFER_SIZE);
1091 then the C preprocessor will recognize and "expand" the macro
1092 `BUFFER_SIZE'. The C compiler will see the same tokens as it would if
1095 foo = (char *) malloc (1024);
1097 By convention, macro names are written in uppercase. Programs are
1098 easier to read when it is possible to tell at a glance which names are
1101 The macro's body ends at the end of the `#define' line. You may
1102 continue the definition onto multiple lines, if necessary, using
1103 backslash-newline. When the macro is expanded, however, it will all
1104 come out on one line. For example,
1106 #define NUMBERS 1, \
1109 int x[] = { NUMBERS };
1110 ==> int x[] = { 1, 2, 3 };
1112 The most common visible consequence of this is surprising line numbers
1115 There is no restriction on what can go in a macro body provided it
1116 decomposes into valid preprocessing tokens. Parentheses need not
1117 balance, and the body need not resemble valid C code. (If it does not,
1118 you may get error messages from the C compiler when you use the macro.)
1120 The C preprocessor scans your program sequentially. Macro
1121 definitions take effect at the place you write them. Therefore, the
1122 following input to the C preprocessor
1133 When the preprocessor expands a macro name, the macro's expansion
1134 replaces the macro invocation, then the expansion is examined for more
1135 macros to expand. For example,
1137 #define TABLESIZE BUFSIZE
1138 #define BUFSIZE 1024
1143 `TABLESIZE' is expanded first to produce `BUFSIZE', then that macro is
1144 expanded to produce the final result, `1024'.
1146 Notice that `BUFSIZE' was not defined when `TABLESIZE' was defined.
1147 The `#define' for `TABLESIZE' uses exactly the expansion you
1148 specify--in this case, `BUFSIZE'--and does not check to see whether it
1149 too contains macro names. Only when you _use_ `TABLESIZE' is the
1150 result of its expansion scanned for more macro names.
1152 This makes a difference if you change the definition of `BUFSIZE' at
1153 some point in the source file. `TABLESIZE', defined as shown, will
1154 always expand using the definition of `BUFSIZE' that is currently in
1157 #define BUFSIZE 1020
1158 #define TABLESIZE BUFSIZE
1162 Now `TABLESIZE' expands (in two stages) to `37'.
1164 If the expansion of a macro contains its own name, either directly or
1165 via intermediate macros, it is not expanded again when the expansion is
1166 examined for more macros. This prevents infinite recursion. *Note
1167 Self-Referential Macros::, for the precise details.
1170 File: cpp.info, Node: Function-like Macros, Next: Macro Arguments, Prev: Object-like Macros, Up: Macros
1172 Function-like Macros
1173 ====================
1175 You can also define macros whose use looks like a function call.
1176 These are called "function-like macros". To define a function-like
1177 macro, you use the same `#define' directive, but you put a pair of
1178 parentheses immediately after the macro name. For example,
1180 #define lang_init() c_init()
1184 A function-like macro is only expanded if its name appears with a
1185 pair of parentheses after it. If you write just the name, it is left
1186 alone. This can be useful when you have a function and a macro of the
1187 same name, and you wish to use the function sometimes.
1189 extern void foo(void);
1190 #define foo() /* optimized inline version */
1195 Here the call to `foo()' will use the macro, but the function
1196 pointer will get the address of the real function. If the macro were to
1197 be expanded, it would cause a syntax error.
1199 If you put spaces between the macro name and the parentheses in the
1200 macro definition, that does not define a function-like macro, it defines
1201 an object-like macro whose expansion happens to begin with a pair of
1204 #define lang_init () c_init()
1208 The first two pairs of parentheses in this expansion come from the
1209 macro. The third is the pair that was originally after the macro
1210 invocation. Since `lang_init' is an object-like macro, it does not
1211 consume those parentheses.
1214 File: cpp.info, Node: Macro Arguments, Next: Stringification, Prev: Function-like Macros, Up: Macros
1219 Function-like macros can take "arguments", just like true functions.
1220 To define a macro that uses arguments, you insert "parameters" between
1221 the pair of parentheses in the macro definition that make the macro
1222 function-like. The parameters must be valid C identifiers, separated
1223 by commas and optionally whitespace.
1225 To invoke a macro that takes arguments, you write the name of the
1226 macro followed by a list of "actual arguments" in parentheses, separated
1227 by commas. The invocation of the macro need not be restricted to a
1228 single logical line--it can cross as many lines in the source file as
1229 you wish. The number of arguments you give must match the number of
1230 parameters in the macro definition. When the macro is expanded, each
1231 use of a parameter in its body is replaced by the tokens of the
1232 corresponding argument. (You need not use all of the parameters in the
1235 As an example, here is a macro that computes the minimum of two
1236 numeric values, as it is defined in many C programs, and some uses.
1238 #define min(X, Y) ((X) < (Y) ? (X) : (Y))
1239 x = min(a, b); ==> x = ((a) < (b) ? (a) : (b));
1240 y = min(1, 2); ==> y = ((1) < (2) ? (1) : (2));
1241 z = min(a + 28, *p); ==> z = ((a + 28) < (*p) ? (a + 28) : (*p));
1243 (In this small example you can already see several of the dangers of
1244 macro arguments. *Note Macro Pitfalls::, for detailed explanations.)
1246 Leading and trailing whitespace in each argument is dropped, and all
1247 whitespace between the tokens of an argument is reduced to a single
1248 space. Parentheses within each argument must balance; a comma within
1249 such parentheses does not end the argument. However, there is no
1250 requirement for square brackets or braces to balance, and they do not
1251 prevent a comma from separating arguments. Thus,
1253 macro (array[x = y, x + 1])
1255 passes two arguments to `macro': `array[x = y' and `x + 1]'. If you
1256 want to supply `array[x = y, x + 1]' as an argument, you can write it
1257 as `array[(x = y, x + 1)]', which is equivalent C code.
1259 All arguments to a macro are completely macro-expanded before they
1260 are substituted into the macro body. After substitution, the complete
1261 text is scanned again for macros to expand, including the arguments.
1262 This rule may seem strange, but it is carefully designed so you need
1263 not worry about whether any function call is actually a macro
1264 invocation. You can run into trouble if you try to be too clever,
1265 though. *Note Argument Prescan::, for detailed discussion.
1267 For example, `min (min (a, b), c)' is first expanded to
1269 min (((a) < (b) ? (a) : (b)), (c))
1273 ((((a) < (b) ? (a) : (b))) < (c)
1274 ? (((a) < (b) ? (a) : (b)))
1277 (Line breaks shown here for clarity would not actually be generated.)
1279 You can leave macro arguments empty; this is not an error to the
1280 preprocessor (but many macros will then expand to invalid code). You
1281 cannot leave out arguments entirely; if a macro takes two arguments,
1282 there must be exactly one comma at the top level of its argument list.
1283 Here are some silly examples using `min':
1285 min(, b) ==> (( ) < (b) ? ( ) : (b))
1286 min(a, ) ==> ((a ) < ( ) ? (a ) : ( ))
1287 min(,) ==> (( ) < ( ) ? ( ) : ( ))
1288 min((,),) ==> (((,)) < ( ) ? ((,)) : ( ))
1290 min() error--> macro "min" requires 2 arguments, but only 1 given
1291 min(,,) error--> macro "min" passed 3 arguments, but takes just 2
1293 Whitespace is not a preprocessing token, so if a macro `foo' takes
1294 one argument, `foo ()' and `foo ( )' both supply it an empty argument.
1295 Previous GNU preprocessor implementations and documentation were
1296 incorrect on this point, insisting that a function-like macro that
1297 takes a single argument be passed a space if an empty argument was
1300 Macro parameters appearing inside string literals are not replaced by
1301 their corresponding actual arguments.
1303 #define foo(x) x, "x"
1304 foo(bar) ==> bar, "x"
1307 File: cpp.info, Node: Stringification, Next: Concatenation, Prev: Macro Arguments, Up: Macros
1312 Sometimes you may want to convert a macro argument into a string
1313 constant. Parameters are not replaced inside string constants, but you
1314 can use the `#' preprocessing operator instead. When a macro parameter
1315 is used with a leading `#', the preprocessor replaces it with the
1316 literal text of the actual argument, converted to a string constant.
1317 Unlike normal parameter replacement, the argument is not macro-expanded
1318 first. This is called "stringification".
1320 There is no way to combine an argument with surrounding text and
1321 stringify it all together. Instead, you can write a series of adjacent
1322 string constants and stringified arguments. The preprocessor will
1323 replace the stringified arguments with string constants. The C
1324 compiler will then combine all the adjacent string constants into one
1327 Here is an example of a macro definition that uses stringification:
1329 #define WARN_IF(EXP) \
1331 fprintf (stderr, "Warning: " #EXP "\n"); } \
1334 ==> do { if (x == 0)
1335 fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0);
1337 The argument for `EXP' is substituted once, as-is, into the `if'
1338 statement, and once, stringified, into the argument to `fprintf'. If
1339 `x' were a macro, it would be expanded in the `if' statement, but not
1342 The `do' and `while (0)' are a kludge to make it possible to write
1343 `WARN_IF (ARG);', which the resemblance of `WARN_IF' to a function
1344 would make C programmers want to do; see *Note Swallowing the
1347 Stringification in C involves more than putting double-quote
1348 characters around the fragment. The preprocessor backslash-escapes the
1349 quotes surrounding embedded string constants, and all backslashes
1350 within string and character constants, in order to get a valid C string
1351 constant with the proper contents. Thus, stringifying `p = "foo\n";'
1352 results in "p = \"foo\\n\";". However, backslashes that are not inside
1353 string or character constants are not duplicated: `\n' by itself
1354 stringifies to "\n".
1356 All leading and trailing whitespace in text being stringified is
1357 ignored. Any sequence of whitespace in the middle of the text is
1358 converted to a single space in the stringified result. Comments are
1359 replaced by whitespace long before stringification happens, so they
1360 never appear in stringified text.
1362 There is no way to convert a macro argument into a character
1365 If you want to stringify the result of expansion of a macro argument,
1366 you have to use two levels of macros.
1368 #define xstr(s) str(s)
1378 `s' is stringified when it is used in `str', so it is not
1379 macro-expanded first. But `s' is an ordinary argument to `xstr', so it
1380 is completely macro-expanded before `xstr' itself is expanded (*note
1381 Argument Prescan::). Therefore, by the time `str' gets to its
1382 argument, it has already been macro-expanded.
1385 File: cpp.info, Node: Concatenation, Next: Variadic Macros, Prev: Stringification, Up: Macros
1390 It is often useful to merge two tokens into one while expanding
1391 macros. This is called "token pasting" or "token concatenation". The
1392 `##' preprocessing operator performs token pasting. When a macro is
1393 expanded, the two tokens on either side of each `##' operator are
1394 combined into a single token, which then replaces the `##' and the two
1395 original tokens in the macro expansion. Usually both will be
1396 identifiers, or one will be an identifier and the other a preprocessing
1397 number. When pasted, they make a longer identifier. This isn't the
1398 only valid case. It is also possible to concatenate two numbers (or a
1399 number and a name, such as `1.5' and `e3') into a number. Also,
1400 multi-character operators such as `+=' can be formed by token pasting.
1402 However, two tokens that don't together form a valid token cannot be
1403 pasted together. For example, you cannot concatenate `x' with `+' in
1404 either order. If you try, the preprocessor issues a warning and emits
1405 the two tokens. Whether it puts white space between the tokens is
1406 undefined. It is common to find unnecessary uses of `##' in complex
1407 macros. If you get this warning, it is likely that you can simply
1410 Both the tokens combined by `##' could come from the macro body, but
1411 you could just as well write them as one token in the first place.
1412 Token pasting is most useful when one or both of the tokens comes from a
1413 macro argument. If either of the tokens next to an `##' is a parameter
1414 name, it is replaced by its actual argument before `##' executes. As
1415 with stringification, the actual argument is not macro-expanded first.
1416 If the argument is empty, that `##' has no effect.
1418 Keep in mind that the C preprocessor converts comments to whitespace
1419 before macros are even considered. Therefore, you cannot create a
1420 comment by concatenating `/' and `*'. You can put as much whitespace
1421 between `##' and its operands as you like, including comments, and you
1422 can put comments in arguments that will be concatenated. However, it
1423 is an error if `##' appears at either end of a macro body.
1425 Consider a C program that interprets named commands. There probably
1426 needs to be a table of commands, perhaps an array of structures declared
1432 void (*function) (void);
1435 struct command commands[] =
1437 { "quit", quit_command },
1438 { "help", help_command },
1442 It would be cleaner not to have to give each command name twice,
1443 once in the string constant and once in the function name. A macro
1444 which takes the name of a command as an argument can make this
1445 unnecessary. The string constant can be created with stringification,
1446 and the function name by concatenating the argument with `_command'.
1447 Here is how it is done:
1449 #define COMMAND(NAME) { #NAME, NAME ## _command }
1451 struct command commands[] =
1459 File: cpp.info, Node: Variadic Macros, Next: Predefined Macros, Prev: Concatenation, Up: Macros
1464 A macro can be declared to accept a variable number of arguments
1465 much as a function can. The syntax for defining the macro is similar
1466 to that of a function. Here is an example:
1468 #define eprintf(...) fprintf (stderr, __VA_ARGS__)
1470 This kind of macro is called "variadic". When the macro is invoked,
1471 all the tokens in its argument list after the last named argument (this
1472 macro has none), including any commas, become the "variable argument".
1473 This sequence of tokens replaces the identifier `__VA_ARGS__' in the
1474 macro body wherever it appears. Thus, we have this expansion:
1476 eprintf ("%s:%d: ", input_file, lineno)
1477 ==> fprintf (stderr, "%s:%d: ", input_file, lineno)
1479 The variable argument is completely macro-expanded before it is
1480 inserted into the macro expansion, just like an ordinary argument. You
1481 may use the `#' and `##' operators to stringify the variable argument
1482 or to paste its leading or trailing token with another token. (But see
1483 below for an important special case for `##'.)
1485 If your macro is complicated, you may want a more descriptive name
1486 for the variable argument than `__VA_ARGS__'. CPP permits this, as an
1487 extension. You may write an argument name immediately before the
1488 `...'; that name is used for the variable argument. The `eprintf'
1489 macro above could be written
1491 #define eprintf(args...) fprintf (stderr, args)
1493 using this extension. You cannot use `__VA_ARGS__' and this extension
1496 You can have named arguments as well as variable arguments in a
1497 variadic macro. We could define `eprintf' like this, instead:
1499 #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__)
1501 This formulation looks more descriptive, but unfortunately it is less
1502 flexible: you must now supply at least one argument after the format
1503 string. In standard C, you cannot omit the comma separating the named
1504 argument from the variable arguments. Furthermore, if you leave the
1505 variable argument empty, you will get a syntax error, because there
1506 will be an extra comma after the format string.
1508 eprintf("success!\n", );
1509 ==> fprintf(stderr, "success!\n", );
1511 GNU CPP has a pair of extensions which deal with this problem.
1512 First, you are allowed to leave the variable argument out entirely:
1514 eprintf ("success!\n")
1515 ==> fprintf(stderr, "success!\n", );
1517 Second, the `##' token paste operator has a special meaning when placed
1518 between a comma and a variable argument. If you write
1520 #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)
1522 and the variable argument is left out when the `eprintf' macro is used,
1523 then the comma before the `##' will be deleted. This does _not_ happen
1524 if you pass an empty argument, nor does it happen if the token
1525 preceding `##' is anything other than a comma.
1527 eprintf ("success!\n")
1528 ==> fprintf(stderr, "success!\n");
1530 The above explanation is ambiguous about the case where the only macro
1531 parameter is a variable arguments parameter, as it is meaningless to
1532 try to distinguish whether no argument at all is an empty argument or a
1533 missing argument. In this case the C99 standard is clear that the
1534 comma must remain, however the existing GCC extension used to swallow
1535 the comma. So CPP retains the comma when conforming to a specific C
1536 standard, and drops it otherwise.
1538 C99 mandates that the only place the identifier `__VA_ARGS__' can
1539 appear is in the replacement list of a variadic macro. It may not be
1540 used as a macro name, macro argument name, or within a different type
1541 of macro. It may also be forbidden in open text; the standard is
1542 ambiguous. We recommend you avoid using it except for its defined
1545 Variadic macros are a new feature in C99. GNU CPP has supported them
1546 for a long time, but only with a named variable argument (`args...',
1547 not `...' and `__VA_ARGS__'). If you are concerned with portability to
1548 previous versions of GCC, you should use only named variable arguments.
1549 On the other hand, if you are concerned with portability to other
1550 conforming implementations of C99, you should use only `__VA_ARGS__'.
1552 Previous versions of CPP implemented the comma-deletion extension
1553 much more generally. We have restricted it in this release to minimize
1554 the differences from C99. To get the same effect with both this and
1555 previous versions of GCC, the token preceding the special `##' must be
1556 a comma, and there must be white space between that comma and whatever
1557 comes immediately before it:
1559 #define eprintf(format, args...) fprintf (stderr, format , ##args)
1561 *Note Differences from previous versions::, for the gory details.
1564 File: cpp.info, Node: Predefined Macros, Next: Undefining and Redefining Macros, Prev: Variadic Macros, Up: Macros
1569 Several object-like macros are predefined; you use them without
1570 supplying their definitions. They fall into three classes: standard,
1571 common, and system-specific.
1573 In C++, there is a fourth category, the named operators. They act
1574 like predefined macros, but you cannot undefine them.
1578 * Standard Predefined Macros::
1579 * Common Predefined Macros::
1580 * System-specific Predefined Macros::
1581 * C++ Named Operators::
1584 File: cpp.info, Node: Standard Predefined Macros, Next: Common Predefined Macros, Up: Predefined Macros
1586 Standard Predefined Macros
1587 --------------------------
1589 The standard predefined macros are specified by the relevant
1590 language standards, so they are available with all compilers that
1591 implement those standards. Older compilers may not provide all of
1592 them. Their names all start with double underscores.
1595 This macro expands to the name of the current input file, in the
1596 form of a C string constant. This is the path by which the
1597 preprocessor opened the file, not the short name specified in
1598 `#include' or as the input file name argument. For example,
1599 `"/usr/local/include/myheader.h"' is a possible expansion of this
1603 This macro expands to the current input line number, in the form
1604 of a decimal integer constant. While we call it a predefined
1605 macro, it's a pretty strange macro, since its "definition" changes
1606 with each new line of source code.
1608 `__FILE__' and `__LINE__' are useful in generating an error message
1609 to report an inconsistency detected by the program; the message can
1610 state the source line at which the inconsistency was detected. For
1613 fprintf (stderr, "Internal error: "
1614 "negative string length "
1615 "%d at %s, line %d.",
1616 length, __FILE__, __LINE__);
1618 An `#include' directive changes the expansions of `__FILE__' and
1619 `__LINE__' to correspond to the included file. At the end of that
1620 file, when processing resumes on the input file that contained the
1621 `#include' directive, the expansions of `__FILE__' and `__LINE__'
1622 revert to the values they had before the `#include' (but `__LINE__' is
1623 then incremented by one as processing moves to the line after the
1626 A `#line' directive changes `__LINE__', and may change `__FILE__' as
1627 well. *Note Line Control::.
1629 C99 introduces `__func__', and GCC has provided `__FUNCTION__' for a
1630 long time. Both of these are strings containing the name of the
1631 current function (there are slight semantic differences; see the GCC
1632 manual). Neither of them is a macro; the preprocessor does not know the
1633 name of the current function. They tend to be useful in conjunction
1634 with `__FILE__' and `__LINE__', though.
1637 This macro expands to a string constant that describes the date on
1638 which the preprocessor is being run. The string constant contains
1639 eleven characters and looks like `"Feb 12 1996"'. If the day of
1640 the month is less than 10, it is padded with a space on the left.
1642 If GCC cannot determine the current date, it will emit a warning
1643 message (once per compilation) and `__DATE__' will expand to
1647 This macro expands to a string constant that describes the time at
1648 which the preprocessor is being run. The string constant contains
1649 eight characters and looks like `"23:59:01"'.
1651 If GCC cannot determine the current time, it will emit a warning
1652 message (once per compilation) and `__TIME__' will expand to
1656 In normal operation, this macro expands to the constant 1, to
1657 signify that this compiler conforms to ISO Standard C. If GNU CPP
1658 is used with a compiler other than GCC, this is not necessarily
1659 true; however, the preprocessor always conforms to the standard
1660 unless the `-traditional-cpp' option is used.
1662 This macro is not defined if the `-traditional-cpp' option is used.
1664 On some hosts, the system compiler uses a different convention,
1665 where `__STDC__' is normally 0, but is 1 if the user specifies
1666 strict conformance to the C Standard. CPP follows the host
1667 convention when processing system header files, but when
1668 processing user files `__STDC__' is always 1. This has been
1669 reported to cause problems; for instance, some versions of Solaris
1670 provide X Windows headers that expect `__STDC__' to be either
1671 undefined or 1. *Note Invocation::.
1674 This macro expands to the C Standard's version number, a long
1675 integer constant of the form `YYYYMML' where YYYY and MM are the
1676 year and month of the Standard version. This signifies which
1677 version of the C Standard the compiler conforms to. Like
1678 `__STDC__', this is not necessarily accurate for the entire
1679 implementation, unless GNU CPP is being used with GCC.
1681 The value `199409L' signifies the 1989 C standard as amended in
1682 1994, which is the current default; the value `199901L' signifies
1683 the 1999 revision of the C standard. Support for the 1999
1684 revision is not yet complete.
1686 This macro is not defined if the `-traditional-cpp' option is
1687 used, nor when compiling C++ or Objective-C.
1690 This macro is defined, with value 1, if the compiler's target is a
1691 "hosted environment". A hosted environment has the complete
1692 facilities of the standard C library available.
1695 This macro is defined when the C++ compiler is in use. You can use
1696 `__cplusplus' to test whether a header is compiled by a C compiler
1697 or a C++ compiler. This macro is similar to `__STDC_VERSION__', in
1698 that it expands to a version number. A fully conforming
1699 implementation of the 1998 C++ standard will define this macro to
1700 `199711L'. The GNU C++ compiler is not yet fully conforming, so
1701 it uses `1' instead. It is hoped to complete the implementation
1702 of standard C++ in the near future.
1705 This macro is defined, with value 1, when the Objective-C compiler
1706 is in use. You can use `__OBJC__' to test whether a header is
1707 compiled by a C compiler or a Objective-C compiler.
1710 This macro is defined with value 1 when preprocessing assembly
1714 File: cpp.info, Node: Common Predefined Macros, Next: System-specific Predefined Macros, Prev: Standard Predefined Macros, Up: Predefined Macros
1716 Common Predefined Macros
1717 ------------------------
1719 The common predefined macros are GNU C extensions. They are
1720 available with the same meanings regardless of the machine or operating
1721 system on which you are using GNU C. Their names all start with double
1726 `__GNUC_PATCHLEVEL__'
1727 These macros are defined by all GNU compilers that use the C
1728 preprocessor: C, C++, and Objective-C. Their values are the major
1729 version, minor version, and patch level of the compiler, as integer
1730 constants. For example, GCC 3.2.1 will define `__GNUC__' to 3,
1731 `__GNUC_MINOR__' to 2, and `__GNUC_PATCHLEVEL__' to 1. They are
1732 defined only when the entire compiler is in use; if you invoke the
1733 preprocessor directly, they are not defined.
1735 `__GNUC_PATCHLEVEL__' is new to GCC 3.0; it is also present in the
1736 widely-used development snapshots leading up to 3.0 (which identify
1737 themselves as GCC 2.96 or 2.97, depending on which snapshot you
1740 If all you need to know is whether or not your program is being
1741 compiled by GCC, you can simply test `__GNUC__'. If you need to
1742 write code which depends on a specific version, you must be more
1743 careful. Each time the minor version is increased, the patch
1744 level is reset to zero; each time the major version is increased
1745 (which happens rarely), the minor version and patch level are
1746 reset. If you wish to use the predefined macros directly in the
1747 conditional, you will need to write it like this:
1749 /* Test for GCC > 3.2.0 */
1750 #if __GNUC__ > 3 || \
1751 (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
1752 (__GNUC_MINOR__ == 2 && \
1753 __GNUC_PATCHLEVEL__ > 0))
1755 Another approach is to use the predefined macros to calculate a
1756 single number, then compare that against a threshold:
1758 #define GCC_VERSION (__GNUC__ * 10000 \
1759 + __GNUC_MINOR__ * 100 \
1760 + __GNUC_PATCHLEVEL__)
1762 /* Test for GCC > 3.2.0 */
1763 #if GCC_VERSION > 30200
1765 Many people find this form easier to understand.
1768 The GNU C++ compiler defines this. Testing it is equivalent to
1769 testing `(__GNUC__ && __cplusplus)'.
1772 GCC defines this macro if and only if the `-ansi' switch, or a
1773 `-std' switch specifying strict conformance to some version of ISO
1774 C, was specified when GCC was invoked. It is defined to `1'.
1775 This macro exists primarily to direct GNU libc's header files to
1776 restrict their definitions to the minimal set found in the 1989 C
1780 This macro expands to the name of the main input file, in the form
1781 of a C string constant. This is the source file that was specified
1782 on the command line of the preprocessor or C compiler.
1785 This macro expands to a decimal integer constant that represents
1786 the depth of nesting in include files. The value of this macro is
1787 incremented on every `#include' directive and decremented at the
1788 end of every included file. It starts out at 0, it's value within
1789 the base file specified on the command line.
1792 This macro is defined if the target uses the ELF object format.
1795 This macro expands to a string constant which describes the
1796 version of the compiler in use. You should not rely on its
1797 contents having any particular form, but it can be counted on to
1798 contain at least the release number.
1803 These macros describe the compilation mode. `__OPTIMIZE__' is
1804 defined in all optimizing compilations. `__OPTIMIZE_SIZE__' is
1805 defined if the compiler is optimizing for size, not speed.
1806 `__NO_INLINE__' is defined if no functions will be inlined into
1807 their callers (when not optimizing, or when inlining has been
1808 specifically disabled by `-fno-inline').
1810 These macros cause certain GNU header files to provide optimized
1811 definitions, using macros or inline functions, of system library
1812 functions. You should not use these macros in any way unless you
1813 make sure that programs will execute with the same effect whether
1814 or not they are defined. If they are defined, their value is 1.
1817 GCC defines this macro if and only if the data type `char' is
1818 unsigned on the target machine. It exists to cause the standard
1819 header file `limits.h' to work correctly. You should not use this
1820 macro yourself; instead, refer to the standard macros defined in
1823 `__WCHAR_UNSIGNED__'
1824 Like `__CHAR_UNSIGNED__', this macro is defined if and only if the
1825 data type `wchar_t' is unsigned and the front-end is in C++ mode.
1827 `__REGISTER_PREFIX__'
1828 This macro expands to a single token (not a string constant) which
1829 is the prefix applied to CPU register names in assembly language
1830 for this target. You can use it to write assembly that is usable
1831 in multiple environments. For example, in the `m68k-aout'
1832 environment it expands to nothing, but in the `m68k-coff'
1833 environment it expands to a single `%'.
1835 `__USER_LABEL_PREFIX__'
1836 This macro expands to a single token which is the prefix applied to
1837 user labels (symbols visible to C code) in assembly. For example,
1838 in the `m68k-aout' environment it expands to an `_', but in the
1839 `m68k-coff' environment it expands to nothing.
1841 This macro will have the correct definition even if
1842 `-f(no-)underscores' is in use, but it will not be correct if
1843 target-specific options that adjust this prefix are used (e.g. the
1844 OSF/rose `-mno-underscores' option).
1850 These macros are defined to the correct underlying types for the
1851 `size_t', `ptrdiff_t', `wchar_t', and `wint_t' typedefs,
1852 respectively. They exist to make the standard header files
1853 `stddef.h' and `wchar.h' work correctly. You should not use these
1854 macros directly; instead, include the appropriate headers and use
1858 Defined to the number of bits used in the representation of the
1859 `char' data type. It exists to make the standard header given
1860 numerical limits work correctly. You should not use this macro
1861 directly; instead, include the appropriate headers.
1869 Defined to the maximum value of the `signed char', `wchar_t',
1870 `signed short', `signed int', `signed long', and `signed long
1871 long' types respectively. They exist to make the standard header
1872 given numerical limits work correctly. You should not use these
1873 macros directly; instead, include the appropriate headers.
1875 `__USING_SJLJ_EXCEPTIONS__'
1876 This macro is defined, with value 1, if the compiler uses the old
1877 mechanism based on `setjmp' and `longjmp' for exception handling.
1880 This macro is defined, with value 1, if (and only if) the NeXT
1881 runtime (as in `-fnext-runtime') is in use for Objective-C. If
1882 the GNU runtime is used, this macro is not defined, so that you
1883 can use this macro to determine which runtime (NeXT or GNU) is
1888 These macros are defined, with value 1, if (and only if) the
1889 compilation is for a target where `long int' and pointer both use
1890 64-bits and `int' uses 32-bit.
1893 File: cpp.info, Node: System-specific Predefined Macros, Next: C++ Named Operators, Prev: Common Predefined Macros, Up: Predefined Macros
1895 System-specific Predefined Macros
1896 ---------------------------------
1898 The C preprocessor normally predefines several macros that indicate
1899 what type of system and machine is in use. They are obviously
1900 different on each target supported by GCC. This manual, being for all
1901 systems and machines, cannot tell you what their names are, but you can
1902 use `cpp -dM' to see them all. *Note Invocation::. All system-specific
1903 predefined macros expand to the constant 1, so you can test them with
1904 either `#ifdef' or `#if'.
1906 The C standard requires that all system-specific macros be part of
1907 the "reserved namespace". All names which begin with two underscores,
1908 or an underscore and a capital letter, are reserved for the compiler and
1909 library to use as they wish. However, historically system-specific
1910 macros have had names with no special prefix; for instance, it is common
1911 to find `unix' defined on Unix systems. For all such macros, GCC
1912 provides a parallel macro with two underscores added at the beginning
1913 and the end. If `unix' is defined, `__unix__' will be defined too.
1914 There will never be more than two underscores; the parallel of `_mips'
1917 When the `-ansi' option, or any `-std' option that requests strict
1918 conformance, is given to the compiler, all the system-specific
1919 predefined macros outside the reserved namespace are suppressed. The
1920 parallel macros, inside the reserved namespace, remain defined.
1922 We are slowly phasing out all predefined macros which are outside the
1923 reserved namespace. You should never use them in new programs, and we
1924 encourage you to correct older code to use the parallel macros whenever
1925 you find it. We don't recommend you use the system-specific macros that
1926 are in the reserved namespace, either. It is better in the long run to
1927 check specifically for features you need, using a tool such as
1931 File: cpp.info, Node: C++ Named Operators, Prev: System-specific Predefined Macros, Up: Predefined Macros
1936 In C++, there are eleven keywords which are simply alternate
1937 spellings of operators normally written with punctuation. These
1938 keywords are treated as such even in the preprocessor. They function
1939 as operators in `#if', and they cannot be defined as macros or
1940 poisoned. In C, you can request that those keywords take their C++
1941 meaning by including `iso646.h'. That header defines each one as a
1942 normal object-like macro expanding to the appropriate punctuator.
1944 These are the named operators and their corresponding punctuators:
1946 Named Operator Punctuator
1960 File: cpp.info, Node: Undefining and Redefining Macros, Next: Directives Within Macro Arguments, Prev: Predefined Macros, Up: Macros
1962 Undefining and Redefining Macros
1963 ================================
1965 If a macro ceases to be useful, it may be "undefined" with the
1966 `#undef' directive. `#undef' takes a single argument, the name of the
1967 macro to undefine. You use the bare macro name, even if the macro is
1968 function-like. It is an error if anything appears on the line after
1969 the macro name. `#undef' has no effect if the name is not a macro.
1974 x = FOO; ==> x = FOO;
1976 Once a macro has been undefined, that identifier may be "redefined"
1977 as a macro by a subsequent `#define' directive. The new definition
1978 need not have any resemblance to the old definition.
1980 However, if an identifier which is currently a macro is redefined,
1981 then the new definition must be "effectively the same" as the old one.
1982 Two macro definitions are effectively the same if:
1983 * Both are the same type of macro (object- or function-like).
1985 * All the tokens of the replacement list are the same.
1987 * If there are any parameters, they are the same.
1989 * Whitespace appears in the same places in both. It need not be
1990 exactly the same amount of whitespace, though. Remember that
1991 comments count as whitespace.
1993 These definitions are effectively the same:
1994 #define FOUR (2 + 2)
1995 #define FOUR (2 + 2)
1996 #define FOUR (2 /* two */ + 2)
1999 #define FOUR (2 + 2)
2000 #define FOUR ( 2+2 )
2001 #define FOUR (2 * 2)
2002 #define FOUR(score,and,seven,years,ago) (2 + 2)
2004 If a macro is redefined with a definition that is not effectively the
2005 same as the old one, the preprocessor issues a warning and changes the
2006 macro to use the new definition. If the new definition is effectively
2007 the same, the redefinition is silently ignored. This allows, for
2008 instance, two different headers to define a common macro. The
2009 preprocessor will only complain if the definitions do not match.
2012 File: cpp.info, Node: Directives Within Macro Arguments, Next: Macro Pitfalls, Prev: Undefining and Redefining Macros, Up: Macros
2014 Directives Within Macro Arguments
2015 =================================
2017 Occasionally it is convenient to use preprocessor directives within
2018 the arguments of a macro. The C and C++ standards declare that
2019 behavior in these cases is undefined.
2021 Versions of CPP prior to 3.2 would reject such constructs with an
2022 error message. This was the only syntactic difference between normal
2023 functions and function-like macros, so it seemed attractive to remove
2024 this limitation, and people would often be surprised that they could
2025 not use macros in this way. Moreover, sometimes people would use
2026 conditional compilation in the argument list to a normal library
2027 function like `printf', only to find that after a library upgrade
2028 `printf' had changed to be a function-like macro, and their code would
2029 no longer compile. So from version 3.2 we changed CPP to successfully
2030 process arbitrary directives within macro arguments in exactly the same
2031 way as it would have processed the directive were the function-like
2032 macro invocation not present.
2034 If, within a macro invocation, that macro is redefined, then the new
2035 definition takes effect in time for argument pre-expansion, but the
2036 original definition is still used for argument replacement. Here is a
2037 pathological example:
2049 with the semantics described above.
2052 File: cpp.info, Node: Macro Pitfalls, Prev: Directives Within Macro Arguments, Up: Macros
2057 In this section we describe some special rules that apply to macros
2058 and macro expansion, and point out certain cases in which the rules have
2059 counter-intuitive consequences that you must watch out for.
2064 * Operator Precedence Problems::
2065 * Swallowing the Semicolon::
2066 * Duplication of Side Effects::
2067 * Self-Referential Macros::
2068 * Argument Prescan::
2069 * Newlines in Arguments::
2072 File: cpp.info, Node: Misnesting, Next: Operator Precedence Problems, Up: Macro Pitfalls
2077 When a macro is called with arguments, the arguments are substituted
2078 into the macro body and the result is checked, together with the rest of
2079 the input file, for more macro calls. It is possible to piece together
2080 a macro call coming partially from the macro body and partially from the
2081 arguments. For example,
2083 #define twice(x) (2*(x))
2084 #define call_with_1(x) x(1)
2089 Macro definitions do not have to have balanced parentheses. By
2090 writing an unbalanced open parenthesis in a macro body, it is possible
2091 to create a macro call that begins inside the macro body but ends
2092 outside of it. For example,
2094 #define strange(file) fprintf (file, "%s %d",
2096 strange(stderr) p, 35)
2097 ==> fprintf (stderr, "%s %d", p, 35)
2099 The ability to piece together a macro call can be useful, but the
2100 use of unbalanced open parentheses in a macro body is just confusing,
2101 and should be avoided.
2104 File: cpp.info, Node: Operator Precedence Problems, Next: Swallowing the Semicolon, Prev: Misnesting, Up: Macro Pitfalls
2106 Operator Precedence Problems
2107 ----------------------------
2109 You may have noticed that in most of the macro definition examples
2110 shown above, each occurrence of a macro argument name had parentheses
2111 around it. In addition, another pair of parentheses usually surround
2112 the entire macro definition. Here is why it is best to write macros
2115 Suppose you define a macro as follows,
2117 #define ceil_div(x, y) (x + y - 1) / y
2119 whose purpose is to divide, rounding up. (One use for this operation is
2120 to compute how many `int' objects are needed to hold a certain number
2121 of `char' objects.) Then suppose it is used as follows:
2123 a = ceil_div (b & c, sizeof (int));
2124 ==> a = (b & c + sizeof (int) - 1) / sizeof (int);
2126 This does not do what is intended. The operator-precedence rules of C
2127 make it equivalent to this:
2129 a = (b & (c + sizeof (int) - 1)) / sizeof (int);
2131 What we want is this:
2133 a = ((b & c) + sizeof (int) - 1)) / sizeof (int);
2135 Defining the macro as
2137 #define ceil_div(x, y) ((x) + (y) - 1) / (y)
2139 provides the desired result.
2141 Unintended grouping can result in another way. Consider `sizeof
2142 ceil_div(1, 2)'. That has the appearance of a C expression that would
2143 compute the size of the type of `ceil_div (1, 2)', but in fact it means
2144 something very different. Here is what it expands to:
2146 sizeof ((1) + (2) - 1) / (2)
2148 This would take the size of an integer and divide it by two. The
2149 precedence rules have put the division outside the `sizeof' when it was
2150 intended to be inside.
2152 Parentheses around the entire macro definition prevent such problems.
2153 Here, then, is the recommended way to define `ceil_div':
2155 #define ceil_div(x, y) (((x) + (y) - 1) / (y))
2158 File: cpp.info, Node: Swallowing the Semicolon, Next: Duplication of Side Effects, Prev: Operator Precedence Problems, Up: Macro Pitfalls
2160 Swallowing the Semicolon
2161 ------------------------
2163 Often it is desirable to define a macro that expands into a compound
2164 statement. Consider, for example, the following macro, that advances a
2165 pointer (the argument `p' says where to find it) across whitespace
2168 #define SKIP_SPACES(p, limit) \
2169 { char *lim = (limit); \
2171 if (*p++ != ' ') { \
2174 Here backslash-newline is used to split the macro definition, which must
2175 be a single logical line, so that it resembles the way such code would
2176 be laid out if not part of a macro definition.
2178 A call to this macro might be `SKIP_SPACES (p, lim)'. Strictly
2179 speaking, the call expands to a compound statement, which is a complete
2180 statement with no need for a semicolon to end it. However, since it
2181 looks like a function call, it minimizes confusion if you can use it
2182 like a function call, writing a semicolon afterward, as in `SKIP_SPACES
2185 This can cause trouble before `else' statements, because the
2186 semicolon is actually a null statement. Suppose you write
2189 SKIP_SPACES (p, lim);
2192 The presence of two statements--the compound statement and a null
2193 statement--in between the `if' condition and the `else' makes invalid C
2196 The definition of the macro `SKIP_SPACES' can be altered to solve
2197 this problem, using a `do ... while' statement. Here is how:
2199 #define SKIP_SPACES(p, limit) \
2200 do { char *lim = (limit); \
2202 if (*p++ != ' ') { \
2206 Now `SKIP_SPACES (p, lim);' expands into
2210 which is one statement. The loop executes exactly once; most compilers
2211 generate no extra code for it.
2214 File: cpp.info, Node: Duplication of Side Effects, Next: Self-Referential Macros, Prev: Swallowing the Semicolon, Up: Macro Pitfalls
2216 Duplication of Side Effects
2217 ---------------------------
2219 Many C programs define a macro `min', for "minimum", like this:
2221 #define min(X, Y) ((X) < (Y) ? (X) : (Y))
2223 When you use this macro with an argument containing a side effect,
2226 next = min (x + y, foo (z));
2228 it expands as follows:
2230 next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
2232 where `x + y' has been substituted for `X' and `foo (z)' for `Y'.
2234 The function `foo' is used only once in the statement as it appears
2235 in the program, but the expression `foo (z)' has been substituted twice
2236 into the macro expansion. As a result, `foo' might be called two times
2237 when the statement is executed. If it has side effects or if it takes
2238 a long time to compute, the results might not be what you intended. We
2239 say that `min' is an "unsafe" macro.
2241 The best solution to this problem is to define `min' in a way that
2242 computes the value of `foo (z)' only once. The C language offers no
2243 standard way to do this, but it can be done with GNU extensions as
2247 ({ typeof (X) x_ = (X); \
2248 typeof (Y) y_ = (Y); \
2249 (x_ < y_) ? x_ : y_; })
2251 The `({ ... })' notation produces a compound statement that acts as
2252 an expression. Its value is the value of its last statement. This
2253 permits us to define local variables and assign each argument to one.
2254 The local variables have underscores after their names to reduce the
2255 risk of conflict with an identifier of wider scope (it is impossible to
2256 avoid this entirely). Now each argument is evaluated exactly once.
2258 If you do not wish to use GNU C extensions, the only solution is to
2259 be careful when _using_ the macro `min'. For example, you can
2260 calculate the value of `foo (z)', save it in a variable, and use that
2263 #define min(X, Y) ((X) < (Y) ? (X) : (Y))
2267 next = min (x + y, tem);
2270 (where we assume that `foo' returns type `int').
2273 File: cpp.info, Node: Self-Referential Macros, Next: Argument Prescan, Prev: Duplication of Side Effects, Up: Macro Pitfalls
2275 Self-Referential Macros
2276 -----------------------
2278 A "self-referential" macro is one whose name appears in its
2279 definition. Recall that all macro definitions are rescanned for more
2280 macros to replace. If the self-reference were considered a use of the
2281 macro, it would produce an infinitely large expansion. To prevent this,
2282 the self-reference is not considered a macro call. It is passed into
2283 the preprocessor output unchanged. Consider an example:
2285 #define foo (4 + foo)
2287 where `foo' is also a variable in your program.
2289 Following the ordinary rules, each reference to `foo' will expand
2290 into `(4 + foo)'; then this will be rescanned and will expand into `(4
2291 + (4 + foo))'; and so on until the computer runs out of memory.
2293 The self-reference rule cuts this process short after one step, at
2294 `(4 + foo)'. Therefore, this macro definition has the possibly useful
2295 effect of causing the program to add 4 to the value of `foo' wherever
2296 `foo' is referred to.
2298 In most cases, it is a bad idea to take advantage of this feature. A
2299 person reading the program who sees that `foo' is a variable will not
2300 expect that it is a macro as well. The reader will come across the
2301 identifier `foo' in the program and think its value should be that of
2302 the variable `foo', whereas in fact the value is four greater.
2304 One common, useful use of self-reference is to create a macro which
2305 expands to itself. If you write
2309 then the macro `EPERM' expands to `EPERM'. Effectively, it is left
2310 alone by the preprocessor whenever it's used in running text. You can
2311 tell that it's a macro with `#ifdef'. You might do this if you want to
2312 define numeric constants with an `enum', but have `#ifdef' be true for
2315 If a macro `x' expands to use a macro `y', and the expansion of `y'
2316 refers to the macro `x', that is an "indirect self-reference" of `x'.
2317 `x' is not expanded in this case either. Thus, if we have
2322 then `x' and `y' expand as follows:
2330 Each macro is expanded when it appears in the definition of the other
2331 macro, but not when it indirectly appears in its own definition.
2334 File: cpp.info, Node: Argument Prescan, Next: Newlines in Arguments, Prev: Self-Referential Macros, Up: Macro Pitfalls
2339 Macro arguments are completely macro-expanded before they are
2340 substituted into a macro body, unless they are stringified or pasted
2341 with other tokens. After substitution, the entire macro body, including
2342 the substituted arguments, is scanned again for macros to be expanded.
2343 The result is that the arguments are scanned _twice_ to expand macro
2346 Most of the time, this has no effect. If the argument contained any
2347 macro calls, they are expanded during the first scan. The result
2348 therefore contains no macro calls, so the second scan does not change
2349 it. If the argument were substituted as given, with no prescan, the
2350 single remaining scan would find the same macro calls and produce the
2353 You might expect the double scan to change the results when a
2354 self-referential macro is used in an argument of another macro (*note
2355 Self-Referential Macros::): the self-referential macro would be
2356 expanded once in the first scan, and a second time in the second scan.
2357 However, this is not what happens. The self-references that do not
2358 expand in the first scan are marked so that they will not expand in the
2361 You might wonder, "Why mention the prescan, if it makes no
2362 difference? And why not skip it and make the preprocessor faster?"
2363 The answer is that the prescan does make a difference in three special
2366 * Nested calls to a macro.
2368 We say that "nested" calls to a macro occur when a macro's argument
2369 contains a call to that very macro. For example, if `f' is a macro
2370 that expects one argument, `f (f (1))' is a nested pair of calls to
2371 `f'. The desired expansion is made by expanding `f (1)' and
2372 substituting that into the definition of `f'. The prescan causes
2373 the expected result to happen. Without the prescan, `f (1)' itself
2374 would be substituted as an argument, and the inner use of `f' would
2375 appear during the main scan as an indirect self-reference and
2376 would not be expanded.
2378 * Macros that call other macros that stringify or concatenate.
2380 If an argument is stringified or concatenated, the prescan does not
2381 occur. If you _want_ to expand a macro, then stringify or
2382 concatenate its expansion, you can do that by causing one macro to
2383 call another macro that does the stringification or concatenation.
2384 For instance, if you have
2386 #define AFTERX(x) X_ ## x
2387 #define XAFTERX(x) AFTERX(x)
2388 #define TABLESIZE 1024
2389 #define BUFSIZE TABLESIZE
2391 then `AFTERX(BUFSIZE)' expands to `X_BUFSIZE', and
2392 `XAFTERX(BUFSIZE)' expands to `X_1024'. (Not to `X_TABLESIZE'.
2393 Prescan always does a complete expansion.)
2395 * Macros used in arguments, whose expansions contain unshielded
2398 This can cause a macro expanded on the second scan to be called
2399 with the wrong number of arguments. Here is an example:
2402 #define bar(x) lose(x)
2403 #define lose(x) (1 + (x))
2405 We would like `bar(foo)' to turn into `(1 + (foo))', which would
2406 then turn into `(1 + (a,b))'. Instead, `bar(foo)' expands into
2407 `lose(a,b)', and you get an error because `lose' requires a single
2408 argument. In this case, the problem is easily solved by the same
2409 parentheses that ought to be used to prevent misnesting of
2410 arithmetic operations:
2414 #define bar(x) lose((x))
2416 The extra pair of parentheses prevents the comma in `foo''s
2417 definition from being interpreted as an argument separator.
2421 File: cpp.info, Node: Newlines in Arguments, Prev: Argument Prescan, Up: Macro Pitfalls
2423 Newlines in Arguments
2424 ---------------------
2426 The invocation of a function-like macro can extend over many logical
2427 lines. However, in the present implementation, the entire expansion
2428 comes out on one line. Thus line numbers emitted by the compiler or
2429 debugger refer to the line the invocation started on, which might be
2430 different to the line containing the argument causing the problem.
2432 Here is an example illustrating this:
2434 #define ignore_second_arg(a,b,c) a; c
2436 ignore_second_arg (foo (),
2440 The syntax error triggered by the tokens `syntax error' results in an
2441 error message citing line three--the line of ignore_second_arg-- even
2442 though the problematic code comes from line five.
2444 We consider this a bug, and intend to fix it in the near future.
2447 File: cpp.info, Node: Conditionals, Next: Diagnostics, Prev: Macros, Up: Top
2452 A "conditional" is a directive that instructs the preprocessor to
2453 select whether or not to include a chunk of code in the final token
2454 stream passed to the compiler. Preprocessor conditionals can test
2455 arithmetic expressions, or whether a name is defined as a macro, or both
2456 simultaneously using the special `defined' operator.
2458 A conditional in the C preprocessor resembles in some ways an `if'
2459 statement in C, but it is important to understand the difference between
2460 them. The condition in an `if' statement is tested during the
2461 execution of your program. Its purpose is to allow your program to
2462 behave differently from run to run, depending on the data it is
2463 operating on. The condition in a preprocessing conditional directive is
2464 tested when your program is compiled. Its purpose is to allow different
2465 code to be included in the program depending on the situation at the
2466 time of compilation.
2468 However, the distinction is becoming less clear. Modern compilers
2469 often do test `if' statements when a program is compiled, if their
2470 conditions are known not to vary at run time, and eliminate code which
2471 can never be executed. If you can count on your compiler to do this,
2472 you may find that your program is more readable if you use `if'
2473 statements with constant conditions (perhaps determined by macros). Of
2474 course, you can only use this to exclude code, not type definitions or
2475 other preprocessing directives, and you can only do it if the code
2476 remains syntactically valid when it is not to be used.
2478 GCC version 3 eliminates this kind of never-executed code even when
2479 not optimizing. Older versions did it only when optimizing.
2483 * Conditional Uses::
2484 * Conditional Syntax::
2488 File: cpp.info, Node: Conditional Uses, Next: Conditional Syntax, Up: Conditionals
2493 There are three general reasons to use a conditional.
2495 * A program may need to use different code depending on the machine
2496 or operating system it is to run on. In some cases the code for
2497 one operating system may be erroneous on another operating system;
2498 for example, it might refer to data types or constants that do not
2499 exist on the other system. When this happens, it is not enough to
2500 avoid executing the invalid code. Its mere presence will cause
2501 the compiler to reject the program. With a preprocessing
2502 conditional, the offending code can be effectively excised from
2503 the program when it is not valid.
2505 * You may want to be able to compile the same source file into two
2506 different programs. One version might make frequent time-consuming
2507 consistency checks on its intermediate data, or print the values of
2508 those data for debugging, and the other not.
2510 * A conditional whose condition is always false is one way to
2511 exclude code from the program but keep it as a sort of comment for
2514 Simple programs that do not need system-specific logic or complex
2515 debugging hooks generally will not need to use preprocessing
2519 File: cpp.info, Node: Conditional Syntax, Next: Deleted Code, Prev: Conditional Uses, Up: Conditionals
2524 A conditional in the C preprocessor begins with a "conditional
2525 directive": `#if', `#ifdef' or `#ifndef'.
2536 File: cpp.info, Node: Ifdef, Next: If, Up: Conditional Syntax
2541 The simplest sort of conditional is
2549 This block is called a "conditional group". CONTROLLED TEXT will be
2550 included in the output of the preprocessor if and only if MACRO is
2551 defined. We say that the conditional "succeeds" if MACRO is defined,
2552 "fails" if it is not.
2554 The CONTROLLED TEXT inside of a conditional can include
2555 preprocessing directives. They are executed only if the conditional
2556 succeeds. You can nest conditional groups inside other conditional
2557 groups, but they must be completely nested. In other words, `#endif'
2558 always matches the nearest `#ifdef' (or `#ifndef', or `#if'). Also,
2559 you cannot start a conditional group in one file and end it in another.
2561 Even if a conditional fails, the CONTROLLED TEXT inside it is still
2562 run through initial transformations and tokenization. Therefore, it
2563 must all be lexically valid C. Normally the only way this matters is
2564 that all comments and string literals inside a failing conditional group
2565 must still be properly ended.
2567 The comment following the `#endif' is not required, but it is a good
2568 practice if there is a lot of CONTROLLED TEXT, because it helps people
2569 match the `#endif' to the corresponding `#ifdef'. Older programs
2570 sometimes put MACRO directly after the `#endif' without enclosing it in
2571 a comment. This is invalid code according to the C standard. CPP
2572 accepts it with a warning. It never affects which `#ifndef' the
2575 Sometimes you wish to use some code if a macro is _not_ defined.
2576 You can do this by writing `#ifndef' instead of `#ifdef'. One common
2577 use of `#ifndef' is to include code only the first time a header file
2578 is included. *Note Once-Only Headers::.
2580 Macro definitions can vary between compilations for several reasons.
2581 Here are some samples.
2583 * Some macros are predefined on each kind of machine (*note
2584 System-specific Predefined Macros::). This allows you to provide
2585 code specially tuned for a particular machine.
2587 * System header files define more macros, associated with the
2588 features they implement. You can test these macros with
2589 conditionals to avoid using a system feature on a machine where it
2592 * Macros can be defined or undefined with the `-D' and `-U' command
2593 line options when you compile the program. You can arrange to
2594 compile the same source file into two different programs by
2595 choosing a macro name to specify which program you want, writing
2596 conditionals to test whether or how this macro is defined, and
2597 then controlling the state of the macro with command line options,
2598 perhaps set in the Makefile. *Note Invocation::.
2600 * Your program might have a special header file (often called
2601 `config.h') that is adjusted when the program is compiled. It can
2602 define or not define macros depending on the features of the
2603 system and the desired capabilities of the program. The
2604 adjustment can be automated by a tool such as `autoconf', or done
2608 File: cpp.info, Node: If, Next: Defined, Prev: Ifdef, Up: Conditional Syntax
2613 The `#if' directive allows you to test the value of an arithmetic
2614 expression, rather than the mere existence of one macro. Its syntax is
2620 #endif /* EXPRESSION */
2622 EXPRESSION is a C expression of integer type, subject to stringent
2623 restrictions. It may contain
2625 * Integer constants.
2627 * Character constants, which are interpreted as they would be in
2630 * Arithmetic operators for addition, subtraction, multiplication,
2631 division, bitwise operations, shifts, comparisons, and logical
2632 operations (`&&' and `||'). The latter two obey the usual
2633 short-circuiting rules of standard C.
2635 * Macros. All macros in the expression are expanded before actual
2636 computation of the expression's value begins.
2638 * Uses of the `defined' operator, which lets you check whether macros
2639 are defined in the middle of an `#if'.
2641 * Identifiers that are not macros, which are all considered to be the
2642 number zero. This allows you to write `#if MACRO' instead of
2643 `#ifdef MACRO', if you know that MACRO, when defined, will always
2644 have a nonzero value. Function-like macros used without their
2645 function call parentheses are also treated as zero.
2647 In some contexts this shortcut is undesirable. The `-Wundef'
2648 option causes GCC to warn whenever it encounters an identifier
2649 which is not a macro in an `#if'.
2651 The preprocessor does not know anything about types in the language.
2652 Therefore, `sizeof' operators are not recognized in `#if', and neither
2653 are `enum' constants. They will be taken as identifiers which are not
2654 macros, and replaced by zero. In the case of `sizeof', this is likely
2655 to cause the expression to be invalid.
2657 The preprocessor calculates the value of EXPRESSION. It carries out
2658 all calculations in the widest integer type known to the compiler; on
2659 most machines supported by GCC this is 64 bits. This is not the same
2660 rule as the compiler uses to calculate the value of a constant
2661 expression, and may give different results in some cases. If the value
2662 comes out to be nonzero, the `#if' succeeds and the CONTROLLED TEXT is
2663 included; otherwise it is skipped.
2666 File: cpp.info, Node: Defined, Next: Else, Prev: If, Up: Conditional Syntax
2671 The special operator `defined' is used in `#if' and `#elif'
2672 expressions to test whether a certain name is defined as a macro.
2673 `defined NAME' and `defined (NAME)' are both expressions whose value is
2674 1 if NAME is defined as a macro at the current point in the program,
2675 and 0 otherwise. Thus, `#if defined MACRO' is precisely equivalent to
2678 `defined' is useful when you wish to test more than one macro for
2679 existence at once. For example,
2681 #if defined (__vax__) || defined (__ns16000__)
2683 would succeed if either of the names `__vax__' or `__ns16000__' is
2686 Conditionals written like this:
2688 #if defined BUFSIZE && BUFSIZE >= 1024
2690 can generally be simplified to just `#if BUFSIZE >= 1024', since if
2691 `BUFSIZE' is not defined, it will be interpreted as having the value
2694 If the `defined' operator appears as a result of a macro expansion,
2695 the C standard says the behavior is undefined. GNU cpp treats it as a
2696 genuine `defined' operator and evaluates it normally. It will warn
2697 wherever your code uses this feature if you use the command-line option
2698 `-pedantic', since other compilers may handle it differently.
2701 File: cpp.info, Node: Else, Next: Elif, Prev: Defined, Up: Conditional Syntax
2706 The `#else' directive can be added to a conditional to provide
2707 alternative text to be used if the condition fails. This is what it
2712 #else /* Not EXPRESSION */
2714 #endif /* Not EXPRESSION */
2716 If EXPRESSION is nonzero, the TEXT-IF-TRUE is included and the
2717 TEXT-IF-FALSE is skipped. If EXPRESSION is zero, the opposite happens.
2719 You can use `#else' with `#ifdef' and `#ifndef', too.
2722 File: cpp.info, Node: Elif, Prev: Else, Up: Conditional Syntax
2727 One common case of nested conditionals is used to check for more
2728 than two possible alternatives. For example, you might have
2740 Another conditional directive, `#elif', allows this to be
2741 abbreviated as follows:
2747 #else /* X != 2 and X != 1*/
2749 #endif /* X != 2 and X != 1*/
2751 `#elif' stands for "else if". Like `#else', it goes in the middle
2752 of a conditional group and subdivides it; it does not require a
2753 matching `#endif' of its own. Like `#if', the `#elif' directive
2754 includes an expression to be tested. The text following the `#elif' is
2755 processed only if the original `#if'-condition failed and the `#elif'
2758 More than one `#elif' can go in the same conditional group. Then
2759 the text after each `#elif' is processed only if the `#elif' condition
2760 succeeds after the original `#if' and all previous `#elif' directives
2761 within it have failed.
2763 `#else' is allowed after any number of `#elif' directives, but
2764 `#elif' may not follow `#else'.
2767 File: cpp.info, Node: Deleted Code, Prev: Conditional Syntax, Up: Conditionals
2772 If you replace or delete a part of the program but want to keep the
2773 old code around for future reference, you often cannot simply comment it
2774 out. Block comments do not nest, so the first comment inside the old
2775 code will end the commenting-out. The probable result is a flood of
2778 One way to avoid this problem is to use an always-false conditional
2779 instead. For instance, put `#if 0' before the deleted code and
2780 `#endif' after it. This works even if the code being turned off
2781 contains conditionals, but they must be entire conditionals (balanced
2782 `#if' and `#endif').
2784 Some people use `#ifdef notdef' instead. This is risky, because
2785 `notdef' might be accidentally defined as a macro, and then the
2786 conditional would succeed. `#if 0' can be counted on to fail.
2788 Do not use `#if 0' for comments which are not C code. Use a real
2789 comment, instead. The interior of `#if 0' must consist of complete
2790 tokens; in particular, single-quote characters must balance. Comments
2791 often contain unbalanced single-quote characters (known in English as
2792 apostrophes). These confuse `#if 0'. They don't confuse `/*'.
2795 File: cpp.info, Node: Diagnostics, Next: Line Control, Prev: Conditionals, Up: Top
2800 The directive `#error' causes the preprocessor to report a fatal
2801 error. The tokens forming the rest of the line following `#error' are
2802 used as the error message.
2804 You would use `#error' inside of a conditional that detects a
2805 combination of parameters which you know the program does not properly
2806 support. For example, if you know that the program will not run
2807 properly on a VAX, you might write
2810 #error "Won't work on VAXen. See comments at get_last_object."
2813 If you have several configuration parameters that must be set up by
2814 the installation in a consistent way, you can use conditionals to detect
2815 an inconsistency and report it with `#error'. For example,
2817 #if !defined(UNALIGNED_INT_ASM_OP) && defined(DWARF2_DEBUGGING_INFO)
2818 #error "DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP."
2821 The directive `#warning' is like `#error', but causes the
2822 preprocessor to issue a warning and continue preprocessing. The tokens
2823 following `#warning' are used as the warning message.
2825 You might use `#warning' in obsolete header files, with a message
2826 directing the user to the header file which should be used instead.
2828 Neither `#error' nor `#warning' macro-expands its argument.
2829 Internal whitespace sequences are each replaced with a single space.
2830 The line must consist of complete tokens. It is wisest to make the
2831 argument of these directives be a single string constant; this avoids
2832 problems with apostrophes and the like.
2835 File: cpp.info, Node: Line Control, Next: Pragmas, Prev: Diagnostics, Up: Top
2840 The C preprocessor informs the C compiler of the location in your
2841 source code where each token came from. Presently, this is just the
2842 file name and line number. All the tokens resulting from macro
2843 expansion are reported as having appeared on the line of the source
2844 file where the outermost macro was used. We intend to be more accurate
2847 If you write a program which generates source code, such as the
2848 `bison' parser generator, you may want to adjust the preprocessor's
2849 notion of the current file name and line number by hand. Parts of the
2850 output from `bison' are generated from scratch, other parts come from a
2851 standard parser file. The rest are copied verbatim from `bison''s
2852 input. You would like compiler error messages and symbolic debuggers
2853 to be able to refer to `bison''s input file.
2855 `bison' or any such program can arrange this by writing `#line'
2856 directives into the output file. `#line' is a directive that specifies
2857 the original line number and source file name for subsequent input in
2858 the current preprocessor input file. `#line' has three variants:
2861 LINENUM is a non-negative decimal integer constant. It specifies
2862 the line number which should be reported for the following line of
2863 input. Subsequent lines are counted from LINENUM.
2865 `#line LINENUM FILENAME'
2866 LINENUM is the same as for the first form, and has the same
2867 effect. In addition, FILENAME is a string constant. The
2868 following line and all subsequent lines are reported to come from
2869 the file it specifies, until something else happens to change that.
2870 FILENAME is interpreted according to the normal rules for a string
2871 constant: backslash escapes are interpreted. This is different
2874 Previous versions of CPP did not interpret escapes in `#line'; we
2875 have changed it because the standard requires they be interpreted,
2876 and most other compilers do.
2878 `#line ANYTHING ELSE'
2879 ANYTHING ELSE is checked for macro calls, which are expanded. The
2880 result should match one of the above two forms.
2882 `#line' directives alter the results of the `__FILE__' and
2883 `__LINE__' predefined macros from that point on. *Note Standard
2884 Predefined Macros::. They do not have any effect on `#include''s idea
2885 of the directory containing the current file. This is a change from
2886 GCC 2.95. Previously, a file reading
2888 #line 1 "../src/gram.y"
2891 would search for `gram.h' in `../src', then the `-I' chain; the
2892 directory containing the physical source file would not be searched.
2893 In GCC 3.0 and later, the `#include' is not affected by the presence of
2894 a `#line' referring to a different directory.
2896 We made this change because the old behavior caused problems when
2897 generated source files were transported between machines. For instance,
2898 it is common practice to ship generated parsers with a source release,
2899 so that people building the distribution do not need to have yacc or
2900 Bison installed. These files frequently have `#line' directives
2901 referring to the directory tree of the system where the distribution was
2902 created. If GCC tries to search for headers in those directories, the
2903 build is likely to fail.
2905 The new behavior can cause failures too, if the generated file is not
2906 in the same directory as its source and it attempts to include a header
2907 which would be visible searching from the directory containing the
2908 source file. However, this problem is easily solved with an additional
2909 `-I' switch on the command line. The failures caused by the old
2910 semantics could sometimes be corrected only by editing the generated
2911 files, which is difficult and error-prone.
2914 File: cpp.info, Node: Pragmas, Next: Other Directives, Prev: Line Control, Up: Top
2919 The `#pragma' directive is the method specified by the C standard
2920 for providing additional information to the compiler, beyond what is
2921 conveyed in the language itself. Three forms of this directive
2922 (commonly known as "pragmas") are specified by the 1999 C standard. A
2923 C compiler is free to attach any meaning it likes to other pragmas.
2925 GCC has historically preferred to use extensions to the syntax of the
2926 language, such as `__attribute__', for this purpose. However, GCC does
2927 define a few pragmas of its own. These mostly have effects on the
2928 entire translation unit or source file.
2930 In GCC version 3, all GNU-defined, supported pragmas have been given
2931 a `GCC' prefix. This is in line with the `STDC' prefix on all pragmas
2932 defined by C99. For backward compatibility, pragmas which were
2933 recognized by previous versions are still recognized without the `GCC'
2934 prefix, but that usage is deprecated. Some older pragmas are
2935 deprecated in their entirety. They are not recognized with the `GCC'
2936 prefix. *Note Obsolete Features::.
2938 C99 introduces the `_Pragma' operator. This feature addresses a
2939 major problem with `#pragma': being a directive, it cannot be produced
2940 as the result of macro expansion. `_Pragma' is an operator, much like
2941 `sizeof' or `defined', and can be embedded in a macro.
2943 Its syntax is `_Pragma (STRING-LITERAL)', where STRING-LITERAL can
2944 be either a normal or wide-character string literal. It is
2945 destringized, by replacing all `\\' with a single `\' and all `\"' with
2946 a `"'. The result is then processed as if it had appeared as the right
2947 hand side of a `#pragma' directive. For example,
2949 _Pragma ("GCC dependency \"parse.y\"")
2951 has the same effect as `#pragma GCC dependency "parse.y"'. The same
2952 effect could be achieved using macros, for example
2954 #define DO_PRAGMA(x) _Pragma (#x)
2955 DO_PRAGMA (GCC dependency "parse.y")
2957 The standard is unclear on where a `_Pragma' operator can appear.
2958 The preprocessor does not accept it within a preprocessing conditional
2959 directive like `#if'. To be safe, you are probably best keeping it out
2960 of directives other than `#define', and putting it on a line of its own.
2962 This manual documents the pragmas which are meaningful to the
2963 preprocessor itself. Other pragmas are meaningful to the C or C++
2964 compilers. They are documented in the GCC manual.
2966 `#pragma GCC dependency'
2967 `#pragma GCC dependency' allows you to check the relative dates of
2968 the current file and another file. If the other file is more
2969 recent than the current file, a warning is issued. This is useful
2970 if the current file is derived from the other file, and should be
2971 regenerated. The other file is searched for using the normal
2972 include search path. Optional trailing text can be used to give
2973 more information in the warning message.
2975 #pragma GCC dependency "parse.y"
2976 #pragma GCC dependency "/usr/include/time.h" rerun fixincludes
2978 `#pragma GCC poison'
2979 Sometimes, there is an identifier that you want to remove
2980 completely from your program, and make sure that it never creeps
2981 back in. To enforce this, you can "poison" the identifier with
2982 this pragma. `#pragma GCC poison' is followed by a list of
2983 identifiers to poison. If any of those identifiers appears
2984 anywhere in the source after the directive, it is a hard error.
2987 #pragma GCC poison printf sprintf fprintf
2988 sprintf(some_string, "hello");
2990 will produce an error.
2992 If a poisoned identifier appears as part of the expansion of a
2993 macro which was defined before the identifier was poisoned, it
2994 will _not_ cause an error. This lets you poison an identifier
2995 without worrying about system headers defining macros that use it.
2999 #define strrchr rindex
3000 #pragma GCC poison rindex
3001 strrchr(some_string, 'h');
3003 will not produce an error.
3005 `#pragma GCC system_header'
3006 This pragma takes no arguments. It causes the rest of the code in
3007 the current file to be treated as if it came from a system header.
3008 *Note System Headers::.
3011 File: cpp.info, Node: Other Directives, Next: Preprocessor Output, Prev: Pragmas, Up: Top
3016 The `#ident' directive takes one argument, a string constant. On
3017 some systems, that string constant is copied into a special segment of
3018 the object file. On other systems, the directive is ignored.
3020 This directive is not part of the C standard, but it is not an
3021 official GNU extension either. We believe it came from System V.
3023 The `#sccs' directive is recognized, because it appears in the
3024 header files of some systems. It is a very old, obscure, extension
3025 which we did not invent, and we have been unable to find any
3026 documentation of what it should do, so GCC simply ignores it.
3028 The "null directive" consists of a `#' followed by a newline, with
3029 only whitespace (including comments) in between. A null directive is
3030 understood as a preprocessing directive but has no effect on the
3031 preprocessor output. The primary significance of the existence of the
3032 null directive is that an input line consisting of just a `#' will
3033 produce no output, rather than a line of output containing just a `#'.
3034 Supposedly some old C programs contain such lines.
3037 File: cpp.info, Node: Preprocessor Output, Next: Traditional Mode, Prev: Other Directives, Up: Top
3042 When the C preprocessor is used with the C, C++, or Objective-C
3043 compilers, it is integrated into the compiler and communicates a stream
3044 of binary tokens directly to the compiler's parser. However, it can
3045 also be used in the more conventional standalone mode, where it produces
3048 The output from the C preprocessor looks much like the input, except
3049 that all preprocessing directive lines have been replaced with blank
3050 lines and all comments with spaces. Long runs of blank lines are
3053 The ISO standard specifies that it is implementation defined whether
3054 a preprocessor preserves whitespace between tokens, or replaces it with
3055 e.g. a single space. In GNU CPP, whitespace between tokens is collapsed
3056 to become a single space, with the exception that the first token on a
3057 non-directive line is preceded with sufficient spaces that it appears in
3058 the same column in the preprocessed output that it appeared in the
3059 original source file. This is so the output is easy to read. *Note
3060 Differences from previous versions::. CPP does not insert any
3061 whitespace where there was none in the original source, except where
3062 necessary to prevent an accidental token paste.
3064 Source file name and line number information is conveyed by lines of
3067 # LINENUM FILENAME FLAGS
3069 These are called "linemarkers". They are inserted as needed into the
3070 output (but never within a string or character constant). They mean
3071 that the following line originated in file FILENAME at line LINENUM.
3072 FILENAME will never contain any non-printing characters; they are
3073 replaced with octal escape sequences.
3075 After the file name comes zero or more flags, which are `1', `2',
3076 `3', or `4'. If there are multiple flags, spaces separate them. Here
3077 is what the flags mean:
3080 This indicates the start of a new file.
3083 This indicates returning to a file (after having included another
3087 This indicates that the following text comes from a system header
3088 file, so certain warnings should be suppressed.
3091 This indicates that the following text should be treated as being
3092 wrapped in an implicit `extern "C"' block.
3094 As an extension, the preprocessor accepts linemarkers in
3095 non-assembler input files. They are treated like the corresponding
3096 `#line' directive, (*note Line Control::), except that trailing flags
3097 are permitted, and are interpreted with the meanings described above.
3098 If multiple flags are given, they must be in ascending order.
3100 Some directives may be duplicated in the output of the preprocessor.
3101 These are `#ident' (always), `#pragma' (only if the preprocessor does
3102 not handle the pragma itself), and `#define' and `#undef' (with certain
3103 debugging options). If this happens, the `#' of the directive will
3104 always be in the first column, and there will be no space between the
3105 `#' and the directive name. If macro expansion happens to generate
3106 tokens which might be mistaken for a duplicated directive, a space will
3107 be inserted between the `#' and the directive name.
3110 File: cpp.info, Node: Traditional Mode, Next: Implementation Details, Prev: Preprocessor Output, Up: Top
3115 Traditional (pre-standard) C preprocessing is rather different from
3116 the preprocessing specified by the standard. When GCC is given the
3117 `-traditional-cpp' option, it attempts to emulate a traditional
3120 GCC versions 3.2 and later only support traditional mode semantics in
3121 the preprocessor, and not in the compiler front ends. This chapter
3122 outlines the traditional preprocessor semantics we implemented.
3124 The implementation does not correspond precisely to the behavior of
3125 earlier versions of GCC, nor to any true traditional preprocessor.
3126 After all, inconsistencies among traditional implementations were a
3127 major motivation for C standardization. However, we intend that it
3128 should be compatible with true traditional preprocessors in all ways
3129 that actually matter.
3133 * Traditional lexical analysis::
3134 * Traditional macros::
3135 * Traditional miscellany::
3136 * Traditional warnings::
3139 File: cpp.info, Node: Traditional lexical analysis, Next: Traditional macros, Up: Traditional Mode
3141 Traditional lexical analysis
3142 ============================
3144 The traditional preprocessor does not decompose its input into tokens
3145 the same way a standards-conforming preprocessor does. The input is
3146 simply treated as a stream of text with minimal internal form.
3148 This implementation does not treat trigraphs (*note trigraphs::)
3149 specially since they were an invention of the standards committee. It
3150 handles arbitrarily-positioned escaped newlines properly and splices
3151 the lines as you would expect; many traditional preprocessors did not
3154 The form of horizontal whitespace in the input file is preserved in
3155 the output. In particular, hard tabs remain hard tabs. This can be
3156 useful if, for example, you are preprocessing a Makefile.
3158 Traditional CPP only recognizes C-style block comments, and treats
3159 the `/*' sequence as introducing a comment only if it lies outside
3160 quoted text. Quoted text is introduced by the usual single and double
3161 quotes, and also by an initial `<' in a `#include' directive.
3163 Traditionally, comments are completely removed and are not replaced
3164 with a space. Since a traditional compiler does its own tokenization
3165 of the output of the preprocessor, this means that comments can
3166 effectively be used as token paste operators. However, comments behave
3167 like separators for text handled by the preprocessor itself, since it
3168 doesn't re-lex its input. For example, in
3172 `foo' and `bar' are distinct identifiers and expanded separately if
3173 they happen to be macros. In other words, this directive is equivalent
3182 Generally speaking, in traditional mode an opening quote need not
3183 have a matching closing quote. In particular, a macro may be defined
3184 with replacement text that contains an unmatched quote. Of course, if
3185 you attempt to compile preprocessed output containing an unmatched quote
3186 you will get a syntax error.
3188 However, all preprocessing directives other than `#define' require
3189 matching quotes. For example:
3191 #define m This macro's fine and has an unmatched quote
3192 "/* This is not a comment. */
3193 /* This is a comment. The following #include directive
3197 Just as for the ISO preprocessor, what would be a closing quote can
3198 be escaped with a backslash to prevent the quoted text from closing.
3201 File: cpp.info, Node: Traditional macros, Next: Traditional miscellany, Prev: Traditional lexical analysis, Up: Traditional Mode
3206 The major difference between traditional and ISO macros is that the
3207 former expand to text rather than to a token sequence. CPP removes all
3208 leading and trailing horizontal whitespace from a macro's replacement
3209 text before storing it, but preserves the form of internal whitespace.
3211 One consequence is that it is legitimate for the replacement text to
3212 contain an unmatched quote (*note Traditional lexical analysis::). An
3213 unclosed string or character constant continues into the text following
3214 the macro call. Similarly, the text at the end of a macro's expansion
3215 can run together with the text after the macro invocation to produce a
3218 Normally comments are removed from the replacement text after the
3219 macro is expanded, but if the `-CC' option is passed on the command
3220 line comments are preserved. (In fact, the current implementation
3221 removes comments even before saving the macro replacement text, but it
3222 careful to do it in such a way that the observed effect is identical
3223 even in the function-like macro case.)
3225 The ISO stringification operator `#' and token paste operator `##'
3226 have no special meaning. As explained later, an effect similar to
3227 these operators can be obtained in a different way. Macro names that
3228 are embedded in quotes, either from the main file or after macro
3229 replacement, do not expand.
3231 CPP replaces an unquoted object-like macro name with its replacement
3232 text, and then rescans it for further macros to replace. Unlike
3233 standard macro expansion, traditional macro expansion has no provision
3234 to prevent recursion. If an object-like macro appears unquoted in its
3235 replacement text, it will be replaced again during the rescan pass, and
3236 so on _ad infinitum_. GCC detects when it is expanding recursive
3237 macros, emits an error message, and continues after the offending macro
3241 #define INC(x) PLUS+x
3245 Function-like macros are similar in form but quite different in
3246 behavior to their ISO counterparts. Their arguments are contained
3247 within parentheses, are comma-separated, and can cross physical lines.
3248 Commas within nested parentheses are not treated as argument
3249 separators. Similarly, a quote in an argument cannot be left unclosed;
3250 a following comma or parenthesis that comes before the closing quote is
3251 treated like any other character. There is no facility for handling
3254 This implementation removes all comments from macro arguments, unless
3255 the `-C' option is given. The form of all other horizontal whitespace
3256 in arguments is preserved, including leading and trailing whitespace.
3261 is treated as an invocation of the macro `f' with a single argument
3262 consisting of a single space. If you want to invoke a function-like
3263 macro that takes no arguments, you must not leave any whitespace
3264 between the parentheses.
3266 If a macro argument crosses a new line, the new line is replaced with
3267 a space when forming the argument. If the previous line contained an
3268 unterminated quote, the following line inherits the quoted state.
3270 Traditional preprocessors replace parameters in the replacement text
3271 with their arguments regardless of whether the parameters are within
3272 quotes or not. This provides a way to stringize arguments. For example
3275 str(/* A comment */some text )
3278 Note that the comment is removed, but that the trailing space is
3279 preserved. Here is an example of using a comment to effect token
3282 #define suffix(x) foo_/**/x
3287 File: cpp.info, Node: Traditional miscellany, Next: Traditional warnings, Prev: Traditional macros, Up: Traditional Mode
3289 Traditional miscellany
3290 ======================
3292 Here are some things to be aware of when using the traditional
3295 * Preprocessing directives are recognized only when their leading
3296 `#' appears in the first column. There can be no whitespace
3297 between the beginning of the line and the `#', but whitespace can
3300 * A true traditional C preprocessor does not recognize `#error' or
3301 `#pragma', and may not recognize `#elif'. CPP supports all the
3302 directives in traditional mode that it supports in ISO mode,
3303 including extensions, with the exception that the effects of
3304 `#pragma GCC poison' are undefined.
3306 * __STDC__ is not defined.
3308 * If you use digraphs the behavior is undefined.
3310 * If a line that looks like a directive appears within macro
3311 arguments, the behavior is undefined.
3315 File: cpp.info, Node: Traditional warnings, Prev: Traditional miscellany, Up: Traditional Mode
3317 Traditional warnings
3318 ====================
3320 You can request warnings about features that did not exist, or worked
3321 differently, in traditional C with the `-Wtraditional' option. GCC
3322 does not warn about features of ISO C which you must use when you are
3323 using a conforming compiler, such as the `#' and `##' operators.
3325 Presently `-Wtraditional' warns about:
3327 * Macro parameters that appear within string literals in the macro
3328 body. In traditional C macro replacement takes place within
3329 string literals, but does not in ISO C.
3331 * In traditional C, some preprocessor directives did not exist.
3332 Traditional preprocessors would only consider a line to be a
3333 directive if the `#' appeared in column 1 on the line. Therefore
3334 `-Wtraditional' warns about directives that traditional C
3335 understands but would ignore because the `#' does not appear as the
3336 first character on the line. It also suggests you hide directives
3337 like `#pragma' not understood by traditional C by indenting them.
3338 Some traditional implementations would not recognize `#elif', so it
3339 suggests avoiding it altogether.
3341 * A function-like macro that appears without an argument list. In
3342 some traditional preprocessors this was an error. In ISO C it
3343 merely means that the macro is not expanded.
3345 * The unary plus operator. This did not exist in traditional C.
3347 * The `U' and `LL' integer constant suffixes, which were not
3348 available in traditional C. (Traditional C does support the `L'
3349 suffix for simple long integer constants.) You are not warned
3350 about uses of these suffixes in macros defined in system headers.
3351 For instance, `UINT_MAX' may well be defined as `4294967295U', but
3352 you will not be warned if you use `UINT_MAX'.
3354 You can usually avoid the warning, and the related warning about
3355 constants which are so large that they are unsigned, by writing the
3356 integer constant in question in hexadecimal, with no U suffix.
3357 Take care, though, because this gives the wrong result in exotic
3361 File: cpp.info, Node: Implementation Details, Next: Invocation, Prev: Traditional Mode, Up: Top
3363 Implementation Details
3364 **********************
3366 Here we document details of how the preprocessor's implementation
3367 affects its user-visible behavior. You should try to avoid undue
3368 reliance on behavior described here, as it is possible that it will
3369 change subtly in future implementations.
3371 Also documented here are obsolete features and changes from previous
3376 * Implementation-defined behavior::
3377 * Implementation limits::
3378 * Obsolete Features::
3379 * Differences from previous versions::
3382 File: cpp.info, Node: Implementation-defined behavior, Next: Implementation limits, Up: Implementation Details
3384 Implementation-defined behavior
3385 ===============================
3387 This is how CPP behaves in all the cases which the C standard
3388 describes as "implementation-defined". This term means that the
3389 implementation is free to do what it likes, but must document its choice
3392 * The mapping of physical source file multi-byte characters to the
3393 execution character set.
3395 Currently, CPP requires its input to be ASCII or UTF-8. The
3396 execution character set may be controlled by the user, with the
3397 `-ftarget-charset' and `-ftarget-wide-charset' options.
3399 * Identifier characters.
3401 The C and C++ standards allow identifiers to be composed of `_'
3402 and the alphanumeric characters. C++ and C99 also allow universal
3403 character names (not implemented in GCC), and C99 further permits
3404 implementation-defined characters.
3406 GCC allows the `$' character in identifiers as an extension for
3407 most targets. This is true regardless of the `std=' switch, since
3408 this extension cannot conflict with standards-conforming programs.
3409 When preprocessing assembler, however, dollars are not identifier
3410 characters by default.
3412 Currently the targets that by default do not permit `$' are AVR,
3413 IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX
3414 and BeOS operating systems.
3416 You can override the default with `-fdollars-in-identifiers' or
3417 `fno-dollars-in-identifiers'. *Note fdollars-in-identifiers::.
3419 * Non-empty sequences of whitespace characters.
3421 In textual output, each whitespace sequence is collapsed to a
3422 single space. For aesthetic reasons, the first token on each
3423 non-directive line of output is preceded with sufficient spaces
3424 that it appears in the same column as it did in the original
3427 * The numeric value of character constants in preprocessor
3430 The preprocessor and compiler interpret character constants in the
3431 same way; i.e. escape sequences such as `\a' are given the values
3432 they would have on the target machine.
3434 The compiler values a multi-character character constant a
3435 character at a time, shifting the previous value left by the
3436 number of bits per target character, and then or-ing in the
3437 bit-pattern of the new character truncated to the width of a
3438 target character. The final bit-pattern is given type `int', and
3439 is therefore signed, regardless of whether single characters are
3440 signed or not (a slight change from versions 3.1 and earlier of
3441 GCC). If there are more characters in the constant than would fit
3442 in the target `int' the compiler issues a warning, and the excess
3443 leading characters are ignored.
3445 For example, 'ab' for a target with an 8-bit `char' would be
3447 (int) ((unsigned char) 'a' * 256 + (unsigned char) 'b'), and
3449 (int) ((unsigned char) '\234' * 256 + (unsigned char) 'a').
3451 * Source file inclusion.
3453 For a discussion on how the preprocessor locates header files,
3454 *Note Include Operation::.
3456 * Interpretation of the filename resulting from a macro-expanded
3457 `#include' directive.
3459 *Note Computed Includes::.
3461 * Treatment of a `#pragma' directive that after macro-expansion
3462 results in a standard pragma.
3464 No macro expansion occurs on any `#pragma' directive line, so the
3465 question does not arise.
3467 Note that GCC does not yet implement any of the standard pragmas.
3471 File: cpp.info, Node: Implementation limits, Next: Obsolete Features, Prev: Implementation-defined behavior, Up: Implementation Details
3473 Implementation limits
3474 =====================
3476 CPP has a small number of internal limits. This section lists the
3477 limits which the C standard requires to be no lower than some minimum,
3478 and all the others known. It is intended that there should be as few
3479 limits as possible. If you encounter an undocumented or inconvenient
3480 limit, please report that as a bug. *Note Reporting Bugs: (gcc)Bugs.
3482 Where we say something is limited "only by available memory", that
3483 means that internal data structures impose no intrinsic limit, and space
3484 is allocated with `malloc' or equivalent. The actual limit will
3485 therefore depend on many things, such as the size of other things
3486 allocated by the compiler at the same time, the amount of memory
3487 consumed by other processes on the same computer, etc.
3489 * Nesting levels of `#include' files.
3491 We impose an arbitrary limit of 200 levels, to avoid runaway
3492 recursion. The standard requires at least 15 levels.
3494 * Nesting levels of conditional inclusion.
3496 The C standard mandates this be at least 63. CPP is limited only
3497 by available memory.
3499 * Levels of parenthesized expressions within a full expression.
3501 The C standard requires this to be at least 63. In preprocessor
3502 conditional expressions, it is limited only by available memory.
3504 * Significant initial characters in an identifier or macro name.
3506 The preprocessor treats all characters as significant. The C
3507 standard requires only that the first 63 be significant.
3509 * Number of macros simultaneously defined in a single translation
3512 The standard requires at least 4095 be possible. CPP is limited
3513 only by available memory.
3515 * Number of parameters in a macro definition and arguments in a
3518 We allow `USHRT_MAX', which is no smaller than 65,535. The minimum
3519 required by the standard is 127.
3521 * Number of characters on a logical source line.
3523 The C standard requires a minimum of 4096 be permitted. CPP places
3524 no limits on this, but you may get incorrect column numbers
3525 reported in diagnostics for lines longer than 65,535 characters.
3527 * Maximum size of a source file.
3529 The standard does not specify any lower limit on the maximum size
3530 of a source file. GNU cpp maps files into memory, so it is
3531 limited by the available address space. This is generally at
3532 least two gigabytes. Depending on the operating system, the size
3533 of physical memory may or may not be a limitation.
3537 File: cpp.info, Node: Obsolete Features, Next: Differences from previous versions, Prev: Implementation limits, Up: Implementation Details
3542 CPP has a number of features which are present mainly for
3543 compatibility with older programs. We discourage their use in new code.
3544 In some cases, we plan to remove the feature in a future version of GCC.
3549 * Obsolete once-only headers::
3552 File: cpp.info, Node: Assertions, Next: Obsolete once-only headers, Up: Obsolete Features
3557 "Assertions" are a deprecated alternative to macros in writing
3558 conditionals to test what sort of computer or system the compiled
3559 program will run on. Assertions are usually predefined, but you can
3560 define them with preprocessing directives or command-line options.
3562 Assertions were intended to provide a more systematic way to describe
3563 the compiler's target system. However, in practice they are just as
3564 unpredictable as the system-specific predefined macros. In addition,
3565 they are not part of any standard, and only a few compilers support
3566 them. Therefore, the use of assertions is *less* portable than the use
3567 of system-specific predefined macros. We recommend you do not use them
3570 An assertion looks like this:
3574 PREDICATE must be a single identifier. ANSWER can be any sequence of
3575 tokens; all characters are significant except for leading and trailing
3576 whitespace, and differences in internal whitespace sequences are
3577 ignored. (This is similar to the rules governing macro redefinition.)
3578 Thus, `(x + y)' is different from `(x+y)' but equivalent to
3579 `( x + y )'. Parentheses do not nest inside an answer.
3581 To test an assertion, you write it in an `#if'. For example, this
3582 conditional succeeds if either `vax' or `ns16000' has been asserted as
3583 an answer for `machine'.
3585 #if #machine (vax) || #machine (ns16000)
3587 You can test whether _any_ answer is asserted for a predicate by
3588 omitting the answer in the conditional:
3592 Assertions are made with the `#assert' directive. Its sole argument
3593 is the assertion to make, without the leading `#' that identifies
3594 assertions in conditionals.
3596 #assert PREDICATE (ANSWER)
3598 You may make several assertions with the same predicate and different
3599 answers. Subsequent assertions do not override previous ones for the
3600 same predicate. All the answers for any given predicate are
3601 simultaneously true.
3603 Assertions can be canceled with the `#unassert' directive. It has
3604 the same syntax as `#assert'. In that form it cancels only the answer
3605 which was specified on the `#unassert' line; other answers for that
3606 predicate remain true. You can cancel an entire predicate by leaving
3611 In either form, if no such assertion has been made, `#unassert' has no
3614 You can also make or cancel assertions using command line options.
3618 File: cpp.info, Node: Obsolete once-only headers, Prev: Assertions, Up: Obsolete Features
3620 Obsolete once-only headers
3621 --------------------------
3623 CPP supports two more ways of indicating that a header file should be
3624 read only once. Neither one is as portable as a wrapper `#ifndef', and
3625 we recommend you do not use them in new programs.
3627 In the Objective-C language, there is a variant of `#include' called
3628 `#import' which includes a file, but does so at most once. If you use
3629 `#import' instead of `#include', then you don't need the conditionals
3630 inside the header file to prevent multiple inclusion of the contents.
3631 GCC permits the use of `#import' in C and C++ as well as Objective-C.
3632 However, it is not in standard C or C++ and should therefore not be
3633 used by portable programs.
3635 `#import' is not a well designed feature. It requires the users of
3636 a header file to know that it should only be included once. It is much
3637 better for the header file's implementor to write the file so that users
3638 don't need to know this. Using a wrapper `#ifndef' accomplishes this
3641 In the present implementation, a single use of `#import' will
3642 prevent the file from ever being read again, by either `#import' or
3643 `#include'. You should not rely on this; do not use both `#import' and
3644 `#include' to refer to the same header file.
3646 Another way to prevent a header file from being included more than
3647 once is with the `#pragma once' directive. If `#pragma once' is seen
3648 when scanning a header file, that file will never be read again, no
3651 `#pragma once' does not have the problems that `#import' does, but
3652 it is not recognized by all preprocessors, so you cannot rely on it in
3656 File: cpp.info, Node: Differences from previous versions, Prev: Obsolete Features, Up: Implementation Details
3658 Differences from previous versions
3659 ==================================
3661 This section details behavior which has changed from previous
3662 versions of CPP. We do not plan to change it again in the near future,
3663 but we do not promise not to, either.
3665 The "previous versions" discussed here are 2.95 and before. The
3666 behavior of GCC 3.0 is mostly the same as the behavior of the widely
3667 used 2.96 and 2.97 development snapshots. Where there are differences,
3668 they generally represent bugs in the snapshots.
3670 * Order of evaluation of `#' and `##' operators
3672 The standard does not specify the order of evaluation of a chain of
3673 `##' operators, nor whether `#' is evaluated before, after, or at
3674 the same time as `##'. You should therefore not write any code
3675 which depends on any specific ordering. It is possible to
3676 guarantee an ordering, if you need one, by suitable use of nested
3679 An example of where this might matter is pasting the arguments `1',
3680 `e' and `-2'. This would be fine for left-to-right pasting, but
3681 right-to-left pasting would produce an invalid token `e-2'.
3683 GCC 3.0 evaluates `#' and `##' at the same time and strictly left
3684 to right. Older versions evaluated all `#' operators first, then
3685 all `##' operators, in an unreliable order.
3687 * The form of whitespace between tokens in preprocessor output
3689 *Note Preprocessor Output::, for the current textual format. This
3690 is also the format used by stringification. Normally, the
3691 preprocessor communicates tokens directly to the compiler's
3692 parser, and whitespace does not come up at all.
3694 Older versions of GCC preserved all whitespace provided by the
3695 user and inserted lots more whitespace of their own, because they
3696 could not accurately predict when extra spaces were needed to
3697 prevent accidental token pasting.
3699 * Optional argument when invoking rest argument macros
3701 As an extension, GCC permits you to omit the variable arguments
3702 entirely when you use a variable argument macro. This is
3703 forbidden by the 1999 C standard, and will provoke a pedantic
3704 warning with GCC 3.0. Previous versions accepted it silently.
3706 * `##' swallowing preceding text in rest argument macros
3708 Formerly, in a macro expansion, if `##' appeared before a variable
3709 arguments parameter, and the set of tokens specified for that
3710 argument in the macro invocation was empty, previous versions of
3711 CPP would back up and remove the preceding sequence of
3712 non-whitespace characters (*not* the preceding token). This
3713 extension is in direct conflict with the 1999 C standard and has
3714 been drastically pared back.
3716 In the current version of the preprocessor, if `##' appears between
3717 a comma and a variable arguments parameter, and the variable
3718 argument is omitted entirely, the comma will be removed from the
3719 expansion. If the variable argument is empty, or the token before
3720 `##' is not a comma, then `##' behaves as a normal token paste.
3722 * `#line' and `#include'
3724 The `#line' directive used to change GCC's notion of the
3725 "directory containing the current file," used by `#include' with a
3726 double-quoted header file name. In 3.0 and later, it does not.
3727 *Note Line Control::, for further explanation.
3731 In GCC 2.95 and previous, the string constant argument to `#line'
3732 was treated the same way as the argument to `#include': backslash
3733 escapes were not honored, and the string ended at the second `"'.
3734 This is not compliant with the C standard. In GCC 3.0, an attempt
3735 was made to correct the behavior, so that the string was treated
3736 as a real string constant, but it turned out to be buggy. In 3.1,
3737 the bugs have been fixed. (We are not fixing the bugs in 3.0
3738 because they affect relatively few people and the fix is quite
3743 File: cpp.info, Node: Invocation, Next: Environment Variables, Prev: Implementation Details, Up: Top
3748 Most often when you use the C preprocessor you will not have to
3749 invoke it explicitly: the C compiler will do so automatically.
3750 However, the preprocessor is sometimes useful on its own. All the
3751 options listed here are also acceptable to the C compiler and have the
3752 same meaning, except that the C compiler has different rules for
3753 specifying the output file.
3755 *Note:* Whether you use the preprocessor by way of `gcc' or `cpp',
3756 the "compiler driver" is run first. This program's purpose is to
3757 translate your command into invocations of the programs that do the
3758 actual work. Their command line interfaces are similar but not
3759 identical to the documented interface, and may change without notice.
3761 The C preprocessor expects two file names as arguments, INFILE and
3762 OUTFILE. The preprocessor reads INFILE together with any other files
3763 it specifies with `#include'. All the output generated by the combined
3764 input files is written in OUTFILE.
3766 Either INFILE or OUTFILE may be `-', which as INFILE means to read
3767 from standard input and as OUTFILE means to write to standard output.
3768 Also, if either file is omitted, it means the same as if `-' had been
3769 specified for that file.
3771 Unless otherwise noted, or the option ends in `=', all options which
3772 take an argument may have that argument appear either immediately after
3773 the option, or with a space between option and argument: `-Ifoo' and
3774 `-I foo' have the same effect.
3776 Many options have multi-letter names; therefore multiple
3777 single-letter options may _not_ be grouped: `-dM' is very different from
3781 Predefine NAME as a macro, with definition `1'.
3783 `-D NAME=DEFINITION'
3784 Predefine NAME as a macro, with definition DEFINITION. The
3785 contents of DEFINITION are tokenized and processed as if they
3786 appeared during translation phase three in a `#define' directive.
3787 In particular, the definition will be truncated by embedded
3790 If you are invoking the preprocessor from a shell or shell-like
3791 program you may need to use the shell's quoting syntax to protect
3792 characters such as spaces that have a meaning in the shell syntax.
3794 If you wish to define a function-like macro on the command line,
3795 write its argument list with surrounding parentheses before the
3796 equals sign (if any). Parentheses are meaningful to most shells,
3797 so you will need to quote the option. With `sh' and `csh',
3798 `-D'NAME(ARGS...)=DEFINITION'' works.
3800 `-D' and `-U' options are processed in the order they are given on
3801 the command line. All `-imacros FILE' and `-include FILE' options
3802 are processed after all `-D' and `-U' options.
3805 Cancel any previous definition of NAME, either built in or
3806 provided with a `-D' option.
3809 Do not predefine any system-specific or GCC-specific macros. The
3810 standard predefined macros remain defined. *Note Standard
3811 Predefined Macros::.
3814 Add the directory DIR to the list of directories to be searched
3815 for header files. *Note Search Path::. Directories named by `-I'
3816 are searched before the standard system include directories. If
3817 the directory DIR is a standard system include directory, the
3818 option is ignored to ensure that the default search order for
3819 system directories and the special treatment of system headers are
3820 not defeated (*note System Headers::) .
3823 Write output to FILE. This is the same as specifying FILE as the
3824 second non-option argument to `cpp'. `gcc' has a different
3825 interpretation of a second non-option argument, so you must use
3826 `-o' to specify the output file.
3829 Turns on all optional warnings which are desirable for normal code.
3830 At present this is `-Wcomment', `-Wtrigraphs', `-Wmultichar' and a
3831 warning about integer promotion causing a change of sign in `#if'
3832 expressions. Note that many of the preprocessor's warnings are on
3833 by default and have no options to control them.
3837 Warn whenever a comment-start sequence `/*' appears in a `/*'
3838 comment, or whenever a backslash-newline appears in a `//' comment.
3839 (Both forms have the same effect.)
3842 Most trigraphs in comments cannot affect the meaning of the
3843 program. However, a trigraph that would form an escaped newline
3844 (`??/' at the end of a line) can, by changing where the comment
3845 begins or ends. Therefore, only trigraphs that would form escaped
3846 newlines produce warnings inside a comment.
3848 This option is implied by `-Wall'. If `-Wall' is not given, this
3849 option is still enabled unless trigraphs are enabled. To get
3850 trigraph conversion without warnings, but get the other `-Wall'
3851 warnings, use `-trigraphs -Wall -Wno-trigraphs'.
3854 Warn about certain constructs that behave differently in
3855 traditional and ISO C. Also warn about ISO C constructs that have
3856 no traditional C equivalent, and problematic constructs which
3857 should be avoided. *Note Traditional Mode::.
3860 Warn the first time `#import' is used.
3863 Warn whenever an identifier which is not a macro is encountered in
3864 an `#if' directive, outside of `defined'. Such identifiers are
3868 Warn about macros defined in the main file that are unused. A
3869 macro is "used" if it is expanded or tested for existence at least
3870 once. The preprocessor will also warn if the macro has not been
3871 used at the time it is redefined or undefined.
3873 Built-in macros, macros defined on the command line, and macros
3874 defined in include files are not warned about.
3876 *Note:* If a macro is actually used, but only used in skipped
3877 conditional blocks, then CPP will report it as unused. To avoid
3878 the warning in such a case, you might improve the scope of the
3879 macro's definition by, for example, moving it into the first
3880 skipped block. Alternatively, you could provide a dummy use with
3883 #if defined the_macro_causing_the_warning
3887 Warn whenever an `#else' or an `#endif' are followed by text.
3888 This usually happens in code of the form
3896 The second and third `FOO' should be in comments, but often are not
3897 in older programs. This warning is on by default.
3900 Make all warnings into hard errors. Source code which triggers
3901 warnings will be rejected.
3904 Issue warnings for code in system headers. These are normally
3905 unhelpful in finding bugs in your own code, therefore suppressed.
3906 If you are responsible for the system library, you may want to see
3910 Suppress all warnings, including those which GNU CPP issues by
3914 Issue all the mandatory diagnostics listed in the C standard.
3915 Some of them are left out by default, since they trigger
3916 frequently on harmless code.
3919 Issue all the mandatory diagnostics, and make all mandatory
3920 diagnostics into errors. This includes mandatory diagnostics that
3921 GCC issues without `-pedantic' but treats as warnings.
3924 Instead of outputting the result of preprocessing, output a rule
3925 suitable for `make' describing the dependencies of the main source
3926 file. The preprocessor outputs one `make' rule containing the
3927 object file name for that source file, a colon, and the names of
3928 all the included files, including those coming from `-include' or
3929 `-imacros' command line options.
3931 Unless specified explicitly (with `-MT' or `-MQ'), the object file
3932 name consists of the basename of the source file with any suffix
3933 replaced with object file suffix. If there are many included
3934 files then the rule is split into several lines using `\'-newline.
3935 The rule has no commands.
3937 This option does not suppress the preprocessor's debug output,
3938 such as `-dM'. To avoid mixing such debug output with the
3939 dependency rules you should explicitly specify the dependency
3940 output file with `-MF', or use an environment variable like
3941 `DEPENDENCIES_OUTPUT' (*note Environment Variables::). Debug
3942 output will still be sent to the regular output stream as normal.
3944 Passing `-M' to the driver implies `-E', and suppresses warnings
3945 with an implicit `-w'.
3948 Like `-M' but do not mention header files that are found in system
3949 header directories, nor header files that are included, directly
3950 or indirectly, from such a header.
3952 This implies that the choice of angle brackets or double quotes in
3953 an `#include' directive does not in itself determine whether that
3954 header will appear in `-MM' dependency output. This is a slight
3955 change in semantics from GCC versions 3.0 and earlier.
3958 When used with `-M' or `-MM', specifies a file to write the
3959 dependencies to. If no `-MF' switch is given the preprocessor
3960 sends the rules to the same place it would have sent preprocessed
3963 When used with the driver options `-MD' or `-MMD', `-MF' overrides
3964 the default dependency output file.
3967 In conjunction with an option such as `-M' requesting dependency
3968 generation, `-MG' assumes missing header files are generated files
3969 and adds them to the dependency list without raising an error.
3970 The dependency filename is taken directly from the `#include'
3971 directive without prepending any path. `-MG' also suppresses
3972 preprocessed output, as a missing header file renders this useless.
3974 This feature is used in automatic updating of makefiles.
3977 This option instructs CPP to add a phony target for each dependency
3978 other than the main file, causing each to depend on nothing. These
3979 dummy rules work around errors `make' gives if you remove header
3980 files without updating the `Makefile' to match.
3982 This is typical output:
3984 test.o: test.c test.h
3989 Change the target of the rule emitted by dependency generation. By
3990 default CPP takes the name of the main input file, including any
3991 path, deletes any file suffix such as `.c', and appends the
3992 platform's usual object suffix. The result is the target.
3994 An `-MT' option will set the target to be exactly the string you
3995 specify. If you want multiple targets, you can specify them as a
3996 single argument to `-MT', or use multiple `-MT' options.
3998 For example, `-MT '$(objpfx)foo.o'' might give
4000 $(objpfx)foo.o: foo.c
4003 Same as `-MT', but it quotes any characters which are special to
4004 Make. `-MQ '$(objpfx)foo.o'' gives
4006 $$(objpfx)foo.o: foo.c
4008 The default target is automatically quoted, as if it were given
4012 `-MD' is equivalent to `-M -MF FILE', except that `-E' is not
4013 implied. The driver determines FILE based on whether an `-o'
4014 option is given. If it is, the driver uses its argument but with
4015 a suffix of `.d', otherwise it take the basename of the input file
4016 and applies a `.d' suffix.
4018 If `-MD' is used in conjunction with `-E', any `-o' switch is
4019 understood to specify the dependency output file (but *note -MF:
4020 dashMF.), but if used without `-E', each `-o' is understood to
4021 specify a target object file.
4023 Since `-E' is not implied, `-MD' can be used to generate a
4024 dependency output file as a side-effect of the compilation process.
4027 Like `-MD' except mention only user header files, not system
4033 `-x assembler-with-cpp'
4034 Specify the source language: C, C++, Objective-C, or assembly.
4035 This has nothing to do with standards conformance or extensions;
4036 it merely selects which base syntax to expect. If you give none
4037 of these options, cpp will deduce the language from the extension
4038 of the source file: `.c', `.cc', `.m', or `.S'. Some other common
4039 extensions for C++ and assembly are also recognized. If cpp does
4040 not recognize the extension, it will treat the file as C; this is
4041 the most generic mode.
4043 *Note:* Previous versions of cpp accepted a `-lang' option which
4044 selected both the language and the standards conformance level.
4045 This option has been removed, because it conflicts with the `-l'
4050 Specify the standard to which the code should conform. Currently
4051 CPP knows about C and C++ standards; others may be added in the
4054 STANDARD may be one of:
4057 The ISO C standard from 1990. `c89' is the customary
4058 shorthand for this version of the standard.
4060 The `-ansi' option is equivalent to `-std=c89'.
4063 The 1990 C standard, as amended in 1994.
4069 The revised ISO C standard, published in December 1999.
4070 Before publication, this was known as C9X.
4073 The 1990 C standard plus GNU extensions. This is the default.
4077 The 1999 C standard plus GNU extensions.
4080 The 1998 ISO C++ standard plus amendments.
4083 The same as `-std=c++98' plus GNU extensions. This is the
4084 default for C++ code.
4087 Split the include path. Any directories specified with `-I'
4088 options before `-I-' are searched only for headers requested with
4089 `#include "FILE"'; they are not searched for `#include <FILE>'.
4090 If additional directories are specified with `-I' options after
4091 the `-I-', those directories are searched for all `#include'
4094 In addition, `-I-' inhibits the use of the directory of the current
4095 file directory as the first search directory for `#include "FILE"'.
4096 *Note Search Path::.
4099 Do not search the standard system directories for header files.
4100 Only the directories you have specified with `-I' options (and the
4101 directory of the current file, if appropriate) are searched.
4104 Do not search for header files in the C++-specific standard
4105 directories, but do still search the other standard directories.
4106 (This option is used when building the C++ library.)
4109 Process FILE as if `#include "file"' appeared as the first line of
4110 the primary source file. However, the first directory searched
4111 for FILE is the preprocessor's working directory _instead of_ the
4112 directory containing the main source file. If not found there, it
4113 is searched for in the remainder of the `#include "..."' search
4116 If multiple `-include' options are given, the files are included
4117 in the order they appear on the command line.
4120 Exactly like `-include', except that any output produced by
4121 scanning FILE is thrown away. Macros it defines remain defined.
4122 This allows you to acquire all the macros from a header without
4123 also processing its declarations.
4125 All files specified by `-imacros' are processed before all files
4126 specified by `-include'.
4129 Search DIR for header files, but do it _after_ all directories
4130 specified with `-I' and the standard system directories have been
4131 exhausted. DIR is treated as a system include directory.
4134 Specify PREFIX as the prefix for subsequent `-iwithprefix'
4135 options. If the prefix represents a directory, you should include
4139 `-iwithprefixbefore DIR'
4140 Append DIR to the prefix specified previously with `-iprefix', and
4141 add the resulting directory to the include search path.
4142 `-iwithprefixbefore' puts it in the same place `-I' would;
4143 `-iwithprefix' puts it where `-idirafter' would.
4146 Search DIR for header files, after all directories specified by
4147 `-I' but before the standard system directories. Mark it as a
4148 system directory, so that it gets the same special treatment as is
4149 applied to the standard system directories. *Note System
4152 `-fdollars-in-identifiers'
4153 Accept `$' in identifiers. *Note Identifier characters::.
4156 Indicate to the preprocessor that the input file has already been
4157 preprocessed. This suppresses things like macro expansion,
4158 trigraph conversion, escaped newline splicing, and processing of
4159 most directives. The preprocessor still recognizes and removes
4160 comments, so that you can pass a file preprocessed with `-C' to
4161 the compiler without problems. In this mode the integrated
4162 preprocessor is little more than a tokenizer for the front ends.
4164 `-fpreprocessed' is implicit if the input file has one of the
4165 extensions `.i', `.ii' or `.mi'. These are the extensions that
4166 GCC uses for preprocessed files created by `-save-temps'.
4169 Set the distance between tab stops. This helps the preprocessor
4170 report correct column numbers in warnings or errors, even if tabs
4171 appear on the line. If the value is less than 1 or greater than
4172 100, the option is ignored. The default is 8.
4174 `-fexec-charset=CHARSET'
4175 Set the execution character set, used for string and character
4176 constants. The default is UTF-8. CHARSET can be any encoding
4177 supported by the system's `iconv' library routine.
4179 `-fwide-exec-charset=CHARSET'
4180 Set the wide execution character set, used for wide string and
4181 character constants. The default is UTF-32 or UTF-16, whichever
4182 corresponds to the width of `wchar_t'. As with
4183 `-ftarget-charset', CHARSET can be any encoding supported by the
4184 system's `iconv' library routine; however, you will have problems
4185 with encodings that do not fit exactly in `wchar_t'.
4187 `-finput-charset=CHARSET'
4188 Set the input character set, used for translation from the
4189 character set of the input file to the source character set used
4190 by GCC. If the locale does not specify, or GCC cannot get this
4191 information from the locale, the default is UTF-8. This can be
4192 overridden by either the locale or this command line option.
4193 Currently the command line option takes precedence if there's a
4194 conflict. CHARSET can be any encoding supported by the system's
4195 `iconv' library routine.
4197 `-fworking-directory'
4198 Enable generation of linemarkers in the preprocessor output that
4199 will let the compiler know the current working directory at the
4200 time of preprocessing. When this option is enabled, the
4201 preprocessor will emit, after the initial linemarker, a second
4202 linemarker with the current working directory followed by two
4203 slashes. GCC will use this directory, when it's present in the
4204 preprocessed input, as the directory emitted as the current
4205 working directory in some debugging information formats. This
4206 option is implicitly enabled if debugging information is enabled,
4207 but this can be inhibited with the negated form
4208 `-fno-working-directory'. If the `-P' flag is present in the
4209 command line, this option has no effect, since no `#line'
4210 directives are emitted whatsoever.
4213 Do not print column numbers in diagnostics. This may be necessary
4214 if diagnostics are being scanned by a program that does not
4215 understand the column numbers, such as `dejagnu'.
4217 `-A PREDICATE=ANSWER'
4218 Make an assertion with the predicate PREDICATE and answer ANSWER.
4219 This form is preferred to the older form `-A PREDICATE(ANSWER)',
4220 which is still supported, because it does not use shell special
4221 characters. *Note Assertions::.
4223 `-A -PREDICATE=ANSWER'
4224 Cancel an assertion with the predicate PREDICATE and answer ANSWER.
4227 CHARS is a sequence of one or more of the following characters,
4228 and must not be preceded by a space. Other characters are
4229 interpreted by the compiler proper, or reserved for future
4230 versions of GCC, and so are silently ignored. If you specify
4231 characters whose behavior conflicts, the result is undefined.
4234 Instead of the normal output, generate a list of `#define'
4235 directives for all the macros defined during the execution of
4236 the preprocessor, including predefined macros. This gives
4237 you a way of finding out what is predefined in your version
4238 of the preprocessor. Assuming you have no file `foo.h', the
4241 touch foo.h; cpp -dM foo.h
4243 will show all the predefined macros.
4246 Like `M' except in two respects: it does _not_ include the
4247 predefined macros, and it outputs _both_ the `#define'
4248 directives and the result of preprocessing. Both kinds of
4249 output go to the standard output file.
4252 Like `D', but emit only the macro names, not their expansions.
4255 Output `#include' directives in addition to the result of
4259 Inhibit generation of linemarkers in the output from the
4260 preprocessor. This might be useful when running the preprocessor
4261 on something that is not C code, and will be sent to a program
4262 which might be confused by the linemarkers. *Note Preprocessor
4266 Do not discard comments. All comments are passed through to the
4267 output file, except for comments in processed directives, which
4268 are deleted along with the directive.
4270 You should be prepared for side effects when using `-C'; it causes
4271 the preprocessor to treat comments as tokens in their own right.
4272 For example, comments appearing at the start of what would be a
4273 directive line have the effect of turning that line into an
4274 ordinary source line, since the first token on the line is no
4278 Do not discard comments, including during macro expansion. This is
4279 like `-C', except that comments contained within macros are also
4280 passed through to the output file where the macro is expanded.
4282 In addition to the side-effects of the `-C' option, the `-CC'
4283 option causes all C++-style comments inside a macro to be
4284 converted to C-style comments. This is to prevent later use of
4285 that macro from inadvertently commenting out the remainder of the
4288 The `-CC' option is generally used to support lint comments.
4291 Try to imitate the behavior of old-fashioned C preprocessors, as
4292 opposed to ISO C preprocessors. *Note Traditional Mode::.
4295 Process trigraph sequences. *Note Initial processing::.
4298 Enable special code to work around file systems which only permit
4299 very short file names, such as MS-DOS.
4303 Print text describing all the command line options instead of
4304 preprocessing anything.
4307 Verbose mode. Print out GNU CPP's version number at the beginning
4308 of execution, and report the final form of the include path.
4311 Print the name of each header file used, in addition to other
4312 normal activities. Each name is indented to show how deep in the
4313 `#include' stack it is. Precompiled header files are also
4314 printed, even if they are found to be invalid; an invalid
4315 precompiled header file is printed with `...x' and a valid one
4320 Print out GNU CPP's version number. With one dash, proceed to
4321 preprocess as normal. With two dashes, exit immediately.
4324 File: cpp.info, Node: Environment Variables, Next: GNU Free Documentation License, Prev: Invocation, Up: Top
4326 Environment Variables
4327 *********************
4329 This section describes the environment variables that affect how CPP
4330 operates. You can use them to specify directories or prefixes to use
4331 when searching for include files, or to control dependency output.
4333 Note that you can also specify places to search using options such as
4334 `-I', and control dependency output with options like `-M' (*note
4335 Invocation::). These take precedence over environment variables, which
4336 in turn take precedence over the configuration of GCC.
4340 `CPLUS_INCLUDE_PATH'
4342 Each variable's value is a list of directories separated by a
4343 special character, much like `PATH', in which to look for header
4344 files. The special character, `PATH_SEPARATOR', is
4345 target-dependent and determined at GCC build time. For Microsoft
4346 Windows-based targets it is a semicolon, and for almost all other
4347 targets it is a colon.
4349 `CPATH' specifies a list of directories to be searched as if
4350 specified with `-I', but after any paths given with `-I' options
4351 on the command line. This environment variable is used regardless
4352 of which language is being preprocessed.
4354 The remaining environment variables apply only when preprocessing
4355 the particular language indicated. Each specifies a list of
4356 directories to be searched as if specified with `-isystem', but
4357 after any paths given with `-isystem' options on the command line.
4359 In all these variables, an empty element instructs the compiler to
4360 search its current working directory. Empty elements can appear
4361 at the beginning or end of a path. For instance, if the value of
4362 `CPATH' is `:/special/include', that has the same effect as
4363 `-I. -I/special/include'.
4365 See also *Note Search Path::.
4367 `DEPENDENCIES_OUTPUT'
4368 If this variable is set, its value specifies how to output
4369 dependencies for Make based on the non-system header files
4370 processed by the compiler. System header files are ignored in the
4373 The value of `DEPENDENCIES_OUTPUT' can be just a file name, in
4374 which case the Make rules are written to that file, guessing the
4375 target name from the source file name. Or the value can have the
4376 form `FILE TARGET', in which case the rules are written to file
4377 FILE using TARGET as the target name.
4379 In other words, this environment variable is equivalent to
4380 combining the options `-MM' and `-MF' (*note Invocation::), with
4381 an optional `-MT' switch too.
4383 `SUNPRO_DEPENDENCIES'
4384 This variable is the same as `DEPENDENCIES_OUTPUT' (see above),
4385 except that system header files are not ignored, so it implies
4386 `-M' rather than `-MM'. However, the dependence on the main input
4387 file is omitted. *Note Invocation::.
4390 File: cpp.info, Node: GNU Free Documentation License, Next: Index of Directives, Prev: Environment Variables, Up: Top
4392 GNU Free Documentation License
4393 ******************************
4395 Version 1.2, November 2002
4396 Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
4397 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
4399 Everyone is permitted to copy and distribute verbatim copies
4400 of this license document, but changing it is not allowed.
4404 The purpose of this License is to make a manual, textbook, or other
4405 functional and useful document "free" in the sense of freedom: to
4406 assure everyone the effective freedom to copy and redistribute it,
4407 with or without modifying it, either commercially or
4408 noncommercially. Secondarily, this License preserves for the
4409 author and publisher a way to get credit for their work, while not
4410 being considered responsible for modifications made by others.
4412 This License is a kind of "copyleft", which means that derivative
4413 works of the document must themselves be free in the same sense.
4414 It complements the GNU General Public License, which is a copyleft
4415 license designed for free software.
4417 We have designed this License in order to use it for manuals for
4418 free software, because free software needs free documentation: a
4419 free program should come with manuals providing the same freedoms
4420 that the software does. But this License is not limited to
4421 software manuals; it can be used for any textual work, regardless
4422 of subject matter or whether it is published as a printed book.
4423 We recommend this License principally for works whose purpose is
4424 instruction or reference.
4426 1. APPLICABILITY AND DEFINITIONS
4428 This License applies to any manual or other work, in any medium,
4429 that contains a notice placed by the copyright holder saying it
4430 can be distributed under the terms of this License. Such a notice
4431 grants a world-wide, royalty-free license, unlimited in duration,
4432 to use that work under the conditions stated herein. The
4433 "Document", below, refers to any such manual or work. Any member
4434 of the public is a licensee, and is addressed as "you". You
4435 accept the license if you copy, modify or distribute the work in a
4436 way requiring permission under copyright law.
4438 A "Modified Version" of the Document means any work containing the
4439 Document or a portion of it, either copied verbatim, or with
4440 modifications and/or translated into another language.
4442 A "Secondary Section" is a named appendix or a front-matter section
4443 of the Document that deals exclusively with the relationship of the
4444 publishers or authors of the Document to the Document's overall
4445 subject (or to related matters) and contains nothing that could
4446 fall directly within that overall subject. (Thus, if the Document
4447 is in part a textbook of mathematics, a Secondary Section may not
4448 explain any mathematics.) The relationship could be a matter of
4449 historical connection with the subject or with related matters, or
4450 of legal, commercial, philosophical, ethical or political position
4453 The "Invariant Sections" are certain Secondary Sections whose
4454 titles are designated, as being those of Invariant Sections, in
4455 the notice that says that the Document is released under this
4456 License. If a section does not fit the above definition of
4457 Secondary then it is not allowed to be designated as Invariant.
4458 The Document may contain zero Invariant Sections. If the Document
4459 does not identify any Invariant Sections then there are none.
4461 The "Cover Texts" are certain short passages of text that are
4462 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4463 that says that the Document is released under this License. A
4464 Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4465 be at most 25 words.
4467 A "Transparent" copy of the Document means a machine-readable copy,
4468 represented in a format whose specification is available to the
4469 general public, that is suitable for revising the document
4470 straightforwardly with generic text editors or (for images
4471 composed of pixels) generic paint programs or (for drawings) some
4472 widely available drawing editor, and that is suitable for input to
4473 text formatters or for automatic translation to a variety of
4474 formats suitable for input to text formatters. A copy made in an
4475 otherwise Transparent file format whose markup, or absence of
4476 markup, has been arranged to thwart or discourage subsequent
4477 modification by readers is not Transparent. An image format is
4478 not Transparent if used for any substantial amount of text. A
4479 copy that is not "Transparent" is called "Opaque".
4481 Examples of suitable formats for Transparent copies include plain
4482 ASCII without markup, Texinfo input format, LaTeX input format,
4483 SGML or XML using a publicly available DTD, and
4484 standard-conforming simple HTML, PostScript or PDF designed for
4485 human modification. Examples of transparent image formats include
4486 PNG, XCF and JPG. Opaque formats include proprietary formats that
4487 can be read and edited only by proprietary word processors, SGML or
4488 XML for which the DTD and/or processing tools are not generally
4489 available, and the machine-generated HTML, PostScript or PDF
4490 produced by some word processors for output purposes only.
4492 The "Title Page" means, for a printed book, the title page itself,
4493 plus such following pages as are needed to hold, legibly, the
4494 material this License requires to appear in the title page. For
4495 works in formats which do not have any title page as such, "Title
4496 Page" means the text near the most prominent appearance of the
4497 work's title, preceding the beginning of the body of the text.
4499 A section "Entitled XYZ" means a named subunit of the Document
4500 whose title either is precisely XYZ or contains XYZ in parentheses
4501 following text that translates XYZ in another language. (Here XYZ
4502 stands for a specific section name mentioned below, such as
4503 "Acknowledgements", "Dedications", "Endorsements", or "History".)
4504 To "Preserve the Title" of such a section when you modify the
4505 Document means that it remains a section "Entitled XYZ" according
4508 The Document may include Warranty Disclaimers next to the notice
4509 which states that this License applies to the Document. These
4510 Warranty Disclaimers are considered to be included by reference in
4511 this License, but only as regards disclaiming warranties: any other
4512 implication that these Warranty Disclaimers may have is void and
4513 has no effect on the meaning of this License.
4517 You may copy and distribute the Document in any medium, either
4518 commercially or noncommercially, provided that this License, the
4519 copyright notices, and the license notice saying this License
4520 applies to the Document are reproduced in all copies, and that you
4521 add no other conditions whatsoever to those of this License. You
4522 may not use technical measures to obstruct or control the reading
4523 or further copying of the copies you make or distribute. However,
4524 you may accept compensation in exchange for copies. If you
4525 distribute a large enough number of copies you must also follow
4526 the conditions in section 3.
4528 You may also lend copies, under the same conditions stated above,
4529 and you may publicly display copies.
4531 3. COPYING IN QUANTITY
4533 If you publish printed copies (or copies in media that commonly
4534 have printed covers) of the Document, numbering more than 100, and
4535 the Document's license notice requires Cover Texts, you must
4536 enclose the copies in covers that carry, clearly and legibly, all
4537 these Cover Texts: Front-Cover Texts on the front cover, and
4538 Back-Cover Texts on the back cover. Both covers must also clearly
4539 and legibly identify you as the publisher of these copies. The
4540 front cover must present the full title with all words of the
4541 title equally prominent and visible. You may add other material
4542 on the covers in addition. Copying with changes limited to the
4543 covers, as long as they preserve the title of the Document and
4544 satisfy these conditions, can be treated as verbatim copying in
4547 If the required texts for either cover are too voluminous to fit
4548 legibly, you should put the first ones listed (as many as fit
4549 reasonably) on the actual cover, and continue the rest onto
4552 If you publish or distribute Opaque copies of the Document
4553 numbering more than 100, you must either include a
4554 machine-readable Transparent copy along with each Opaque copy, or
4555 state in or with each Opaque copy a computer-network location from
4556 which the general network-using public has access to download
4557 using public-standard network protocols a complete Transparent
4558 copy of the Document, free of added material. If you use the
4559 latter option, you must take reasonably prudent steps, when you
4560 begin distribution of Opaque copies in quantity, to ensure that
4561 this Transparent copy will remain thus accessible at the stated
4562 location until at least one year after the last time you
4563 distribute an Opaque copy (directly or through your agents or
4564 retailers) of that edition to the public.
4566 It is requested, but not required, that you contact the authors of
4567 the Document well before redistributing any large number of
4568 copies, to give them a chance to provide you with an updated
4569 version of the Document.
4573 You may copy and distribute a Modified Version of the Document
4574 under the conditions of sections 2 and 3 above, provided that you
4575 release the Modified Version under precisely this License, with
4576 the Modified Version filling the role of the Document, thus
4577 licensing distribution and modification of the Modified Version to
4578 whoever possesses a copy of it. In addition, you must do these
4579 things in the Modified Version:
4581 A. Use in the Title Page (and on the covers, if any) a title
4582 distinct from that of the Document, and from those of
4583 previous versions (which should, if there were any, be listed
4584 in the History section of the Document). You may use the
4585 same title as a previous version if the original publisher of
4586 that version gives permission.
4588 B. List on the Title Page, as authors, one or more persons or
4589 entities responsible for authorship of the modifications in
4590 the Modified Version, together with at least five of the
4591 principal authors of the Document (all of its principal
4592 authors, if it has fewer than five), unless they release you
4593 from this requirement.
4595 C. State on the Title page the name of the publisher of the
4596 Modified Version, as the publisher.
4598 D. Preserve all the copyright notices of the Document.
4600 E. Add an appropriate copyright notice for your modifications
4601 adjacent to the other copyright notices.
4603 F. Include, immediately after the copyright notices, a license
4604 notice giving the public permission to use the Modified
4605 Version under the terms of this License, in the form shown in
4608 G. Preserve in that license notice the full lists of Invariant
4609 Sections and required Cover Texts given in the Document's
4612 H. Include an unaltered copy of this License.
4614 I. Preserve the section Entitled "History", Preserve its Title,
4615 and add to it an item stating at least the title, year, new
4616 authors, and publisher of the Modified Version as given on
4617 the Title Page. If there is no section Entitled "History" in
4618 the Document, create one stating the title, year, authors,
4619 and publisher of the Document as given on its Title Page,
4620 then add an item describing the Modified Version as stated in
4621 the previous sentence.
4623 J. Preserve the network location, if any, given in the Document
4624 for public access to a Transparent copy of the Document, and
4625 likewise the network locations given in the Document for
4626 previous versions it was based on. These may be placed in
4627 the "History" section. You may omit a network location for a
4628 work that was published at least four years before the
4629 Document itself, or if the original publisher of the version
4630 it refers to gives permission.
4632 K. For any section Entitled "Acknowledgements" or "Dedications",
4633 Preserve the Title of the section, and preserve in the
4634 section all the substance and tone of each of the contributor
4635 acknowledgements and/or dedications given therein.
4637 L. Preserve all the Invariant Sections of the Document,
4638 unaltered in their text and in their titles. Section numbers
4639 or the equivalent are not considered part of the section
4642 M. Delete any section Entitled "Endorsements". Such a section
4643 may not be included in the Modified Version.
4645 N. Do not retitle any existing section to be Entitled
4646 "Endorsements" or to conflict in title with any Invariant
4649 O. Preserve any Warranty Disclaimers.
4651 If the Modified Version includes new front-matter sections or
4652 appendices that qualify as Secondary Sections and contain no
4653 material copied from the Document, you may at your option
4654 designate some or all of these sections as invariant. To do this,
4655 add their titles to the list of Invariant Sections in the Modified
4656 Version's license notice. These titles must be distinct from any
4657 other section titles.
4659 You may add a section Entitled "Endorsements", provided it contains
4660 nothing but endorsements of your Modified Version by various
4661 parties--for example, statements of peer review or that the text
4662 has been approved by an organization as the authoritative
4663 definition of a standard.
4665 You may add a passage of up to five words as a Front-Cover Text,
4666 and a passage of up to 25 words as a Back-Cover Text, to the end
4667 of the list of Cover Texts in the Modified Version. Only one
4668 passage of Front-Cover Text and one of Back-Cover Text may be
4669 added by (or through arrangements made by) any one entity. If the
4670 Document already includes a cover text for the same cover,
4671 previously added by you or by arrangement made by the same entity
4672 you are acting on behalf of, you may not add another; but you may
4673 replace the old one, on explicit permission from the previous
4674 publisher that added the old one.
4676 The author(s) and publisher(s) of the Document do not by this
4677 License give permission to use their names for publicity for or to
4678 assert or imply endorsement of any Modified Version.
4680 5. COMBINING DOCUMENTS
4682 You may combine the Document with other documents released under
4683 this License, under the terms defined in section 4 above for
4684 modified versions, provided that you include in the combination
4685 all of the Invariant Sections of all of the original documents,
4686 unmodified, and list them all as Invariant Sections of your
4687 combined work in its license notice, and that you preserve all
4688 their Warranty Disclaimers.
4690 The combined work need only contain one copy of this License, and
4691 multiple identical Invariant Sections may be replaced with a single
4692 copy. If there are multiple Invariant Sections with the same name
4693 but different contents, make the title of each such section unique
4694 by adding at the end of it, in parentheses, the name of the
4695 original author or publisher of that section if known, or else a
4696 unique number. Make the same adjustment to the section titles in
4697 the list of Invariant Sections in the license notice of the
4700 In the combination, you must combine any sections Entitled
4701 "History" in the various original documents, forming one section
4702 Entitled "History"; likewise combine any sections Entitled
4703 "Acknowledgements", and any sections Entitled "Dedications". You
4704 must delete all sections Entitled "Endorsements."
4706 6. COLLECTIONS OF DOCUMENTS
4708 You may make a collection consisting of the Document and other
4709 documents released under this License, and replace the individual
4710 copies of this License in the various documents with a single copy
4711 that is included in the collection, provided that you follow the
4712 rules of this License for verbatim copying of each of the
4713 documents in all other respects.
4715 You may extract a single document from such a collection, and
4716 distribute it individually under this License, provided you insert
4717 a copy of this License into the extracted document, and follow
4718 this License in all other respects regarding verbatim copying of
4721 7. AGGREGATION WITH INDEPENDENT WORKS
4723 A compilation of the Document or its derivatives with other
4724 separate and independent documents or works, in or on a volume of
4725 a storage or distribution medium, is called an "aggregate" if the
4726 copyright resulting from the compilation is not used to limit the
4727 legal rights of the compilation's users beyond what the individual
4728 works permit. When the Document is included an aggregate, this
4729 License does not apply to the other works in the aggregate which
4730 are not themselves derivative works of the Document.
4732 If the Cover Text requirement of section 3 is applicable to these
4733 copies of the Document, then if the Document is less than one half
4734 of the entire aggregate, the Document's Cover Texts may be placed
4735 on covers that bracket the Document within the aggregate, or the
4736 electronic equivalent of covers if the Document is in electronic
4737 form. Otherwise they must appear on printed covers that bracket
4738 the whole aggregate.
4742 Translation is considered a kind of modification, so you may
4743 distribute translations of the Document under the terms of section
4744 4. Replacing Invariant Sections with translations requires special
4745 permission from their copyright holders, but you may include
4746 translations of some or all Invariant Sections in addition to the
4747 original versions of these Invariant Sections. You may include a
4748 translation of this License, and all the license notices in the
4749 Document, and any Warrany Disclaimers, provided that you also
4750 include the original English version of this License and the
4751 original versions of those notices and disclaimers. In case of a
4752 disagreement between the translation and the original version of
4753 this License or a notice or disclaimer, the original version will
4756 If a section in the Document is Entitled "Acknowledgements",
4757 "Dedications", or "History", the requirement (section 4) to
4758 Preserve its Title (section 1) will typically require changing the
4763 You may not copy, modify, sublicense, or distribute the Document
4764 except as expressly provided for under this License. Any other
4765 attempt to copy, modify, sublicense or distribute the Document is
4766 void, and will automatically terminate your rights under this
4767 License. However, parties who have received copies, or rights,
4768 from you under this License will not have their licenses
4769 terminated so long as such parties remain in full compliance.
4771 10. FUTURE REVISIONS OF THIS LICENSE
4773 The Free Software Foundation may publish new, revised versions of
4774 the GNU Free Documentation License from time to time. Such new
4775 versions will be similar in spirit to the present version, but may
4776 differ in detail to address new problems or concerns. See
4777 `http://www.gnu.org/copyleft/'.
4779 Each version of the License is given a distinguishing version
4780 number. If the Document specifies that a particular numbered
4781 version of this License "or any later version" applies to it, you
4782 have the option of following the terms and conditions either of
4783 that specified version or of any later version that has been
4784 published (not as a draft) by the Free Software Foundation. If
4785 the Document does not specify a version number of this License,
4786 you may choose any version ever published (not as a draft) by the
4787 Free Software Foundation.
4789 ADDENDUM: How to use this License for your documents
4790 ====================================================
4792 To use this License in a document you have written, include a copy of
4793 the License in the document and put the following copyright and license
4794 notices just after the title page:
4796 Copyright (C) YEAR YOUR NAME.
4797 Permission is granted to copy, distribute and/or modify this document
4798 under the terms of the GNU Free Documentation License, Version 1.2
4799 or any later version published by the Free Software Foundation;
4800 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
4801 A copy of the license is included in the section entitled ``GNU
4802 Free Documentation License''.
4804 If you have Invariant Sections, Front-Cover Texts and Back-Cover
4805 Texts, replace the "with...Texts." line with this:
4807 with the Invariant Sections being LIST THEIR TITLES, with
4808 the Front-Cover Texts being LIST, and with the Back-Cover Texts
4811 If you have Invariant Sections without Cover Texts, or some other
4812 combination of the three, merge those two alternatives to suit the
4815 If your document contains nontrivial examples of program code, we
4816 recommend releasing these examples in parallel under your choice of
4817 free software license, such as the GNU General Public License, to
4818 permit their use in free software.
4821 File: cpp.info, Node: Index of Directives, Next: Option Index, Prev: GNU Free Documentation License, Up: Top
4828 * #assert: Assertions.
4829 * #define: Object-like Macros.
4833 * #error: Diagnostics.
4834 * #ident: Other Directives.
4835 * #if: Conditional Syntax.
4838 * #import: Obsolete once-only headers.
4839 * #include: Include Syntax.
4840 * #include_next: Wrapper Headers.
4841 * #line: Line Control.
4842 * #pragma GCC dependency: Pragmas.
4843 * #pragma GCC poison: Pragmas.
4844 * #pragma GCC system_header <1>: Pragmas.
4845 * #pragma GCC system_header: System Headers.
4846 * #sccs: Other Directives.
4847 * #unassert: Assertions.
4848 * #undef: Undefining and Redefining Macros.
4849 * #warning: Diagnostics.
4852 File: cpp.info, Node: Option Index, Next: Concept Index, Prev: Index of Directives, Up: Top
4857 CPP's command line options and environment variables are indexed here
4858 without any initial `-' or `--'.
4865 * C_INCLUDE_PATH: Environment Variables.
4866 * CPATH: Environment Variables.
4867 * CPLUS_INCLUDE_PATH: Environment Variables.
4870 * DEPENDENCIES_OUTPUT: Environment Variables.
4874 * fdollars-in-identifiers: Invocation.
4875 * fexec-charset: Invocation.
4876 * finput-charset: Invocation.
4877 * fno-show-column: Invocation.
4878 * fno-working-directory: Invocation.
4879 * fpreprocessed: Invocation.
4880 * ftabstop: Invocation.
4881 * fwide-exec-charset: Invocation.
4882 * fworking-directory: Invocation.
4887 * idirafter: Invocation.
4888 * imacros: Invocation.
4889 * include: Invocation.
4890 * iprefix: Invocation.
4891 * isystem: Invocation.
4892 * iwithprefix: Invocation.
4893 * iwithprefixbefore: Invocation.
4903 * nostdinc: Invocation.
4904 * nostdinc++: Invocation.
4906 * OBJC_INCLUDE_PATH: Environment Variables.
4908 * pedantic: Invocation.
4909 * pedantic-errors: Invocation.
4910 * remap: Invocation.
4912 * SUNPRO_DEPENDENCIES: Environment Variables.
4913 * target-help: Invocation.
4914 * traditional-cpp: Invocation.
4915 * trigraphs: Invocation.
4917 * undef: Invocation.
4919 * version: Invocation.
4922 * Wcomment: Invocation.
4923 * Wcomments: Invocation.
4924 * Wendif-labels: Invocation.
4925 * Werror: Invocation.
4926 * Wimport: Invocation.
4927 * Wsystem-headers: Invocation.
4928 * Wtraditional: Invocation.
4929 * Wtrigraphs: Invocation.
4930 * Wundef: Invocation.
4931 * Wunused-macros: Invocation.
4935 File: cpp.info, Node: Concept Index, Prev: Option Index, Up: Top
4942 * # operator: Stringification.
4943 * ## operator: Concatenation.
4945 * alternative tokens: Tokenization.
4946 * arguments: Macro Arguments.
4947 * arguments in macro definitions: Macro Arguments.
4948 * assertions: Assertions.
4949 * assertions, canceling: Assertions.
4950 * backslash-newline: Initial processing.
4951 * block comments: Initial processing.
4952 * C++ named operators: C++ Named Operators.
4953 * character constants: Tokenization.
4954 * command line: Invocation.
4955 * commenting out code: Deleted Code.
4956 * comments: Initial processing.
4957 * common predefined macros: Common Predefined Macros.
4958 * computed includes: Computed Includes.
4959 * concatenation: Concatenation.
4960 * conditional group: Ifdef.
4961 * conditionals: Conditionals.
4962 * continued lines: Initial processing.
4963 * controlling macro: Once-Only Headers.
4965 * dependencies for make as output: Environment Variables.
4966 * dependencies, make: Invocation.
4967 * diagnostic: Diagnostics.
4968 * differences from previous versions: Differences from previous versions.
4969 * digraphs: Tokenization.
4970 * directive line: The preprocessing language.
4971 * directive name: The preprocessing language.
4972 * directives: The preprocessing language.
4973 * empty macro arguments: Macro Arguments.
4974 * environment variables: Environment Variables.
4975 * expansion of arguments: Argument Prescan.
4976 * FDL, GNU Free Documentation License: GNU Free Documentation License.
4977 * function-like macros: Function-like Macros.
4978 * grouping options: Invocation.
4979 * guard macro: Once-Only Headers.
4980 * header file: Header Files.
4981 * header file names: Tokenization.
4982 * identifiers: Tokenization.
4983 * implementation limits: Implementation limits.
4984 * implementation-defined behavior: Implementation-defined behavior.
4985 * including just once: Once-Only Headers.
4986 * invocation: Invocation.
4987 * iso646.h: C++ Named Operators.
4988 * line comments: Initial processing.
4989 * line control: Line Control.
4990 * line endings: Initial processing.
4991 * linemarkers: Preprocessor Output.
4992 * macro argument expansion: Argument Prescan.
4993 * macro arguments and directives: Directives Within Macro Arguments.
4994 * macros in include: Computed Includes.
4995 * macros with arguments: Macro Arguments.
4996 * macros with variable arguments: Variadic Macros.
4998 * manifest constants: Object-like Macros.
4999 * named operators: C++ Named Operators.
5000 * newlines in macro arguments: Newlines in Arguments.
5001 * null directive: Other Directives.
5002 * numbers: Tokenization.
5003 * object-like macro: Object-like Macros.
5004 * options: Invocation.
5005 * options, grouping: Invocation.
5006 * other tokens: Tokenization.
5007 * output format: Preprocessor Output.
5008 * overriding a header file: Wrapper Headers.
5009 * parentheses in macro bodies: Operator Precedence Problems.
5010 * pitfalls of macros: Macro Pitfalls.
5011 * predefined macros: Predefined Macros.
5012 * predefined macros, system-specific: System-specific Predefined Macros.
5013 * predicates: Assertions.
5014 * preprocessing directives: The preprocessing language.
5015 * preprocessing numbers: Tokenization.
5016 * preprocessing tokens: Tokenization.
5017 * prescan of macro arguments: Argument Prescan.
5018 * problems with macros: Macro Pitfalls.
5019 * punctuators: Tokenization.
5020 * redefining macros: Undefining and Redefining Macros.
5021 * repeated inclusion: Once-Only Headers.
5022 * reporting errors: Diagnostics.
5023 * reporting warnings: Diagnostics.
5024 * reserved namespace: System-specific Predefined Macros.
5025 * self-reference: Self-Referential Macros.
5026 * semicolons (after macro calls): Swallowing the Semicolon.
5027 * side effects (in macro arguments): Duplication of Side Effects.
5028 * standard predefined macros.: Standard Predefined Macros.
5029 * string constants: Tokenization.
5030 * string literals: Tokenization.
5031 * stringification: Stringification.
5032 * symbolic constants: Object-like Macros.
5033 * system header files <1>: Header Files.
5034 * system header files: System Headers.
5035 * system-specific predefined macros: System-specific Predefined Macros.
5036 * testing predicates: Assertions.
5037 * token concatenation: Concatenation.
5038 * token pasting: Concatenation.
5039 * tokens: Tokenization.
5040 * trigraphs: Initial processing.
5041 * undefining macros: Undefining and Redefining Macros.
5042 * unsafe macros: Duplication of Side Effects.
5043 * variable number of arguments: Variadic Macros.
5044 * variadic macros: Variadic Macros.
5045 * wrapper #ifndef: Once-Only Headers.
5046 * wrapper headers: Wrapper Headers.
5052 Node: Overview
\x7f2847
5053 Node: Character sets
\x7f6498
5054 Ref: Character sets-Footnote-1
\x7f8952
5055 Node: Initial processing
\x7f9133
5056 Ref: trigraphs
\x7f10687
5057 Node: Tokenization
\x7f14894
5058 Ref: Tokenization-Footnote-1
\x7f21943
5059 Node: The preprocessing language
\x7f22054
5060 Node: Header Files
\x7f24927
5061 Node: Include Syntax
\x7f26805
5062 Node: Include Operation
\x7f28307
5063 Node: Search Path
\x7f30160
5064 Node: Once-Only Headers
\x7f33231
5065 Node: Computed Includes
\x7f34881
5066 Node: Wrapper Headers
\x7f38020
5067 Node: System Headers
\x7f40439
5068 Node: Macros
\x7f42484
5069 Node: Object-like Macros
\x7f43622
5070 Node: Function-like Macros
\x7f47207
5071 Node: Macro Arguments
\x7f48817
5072 Node: Stringification
\x7f52962
5073 Node: Concatenation
\x7f56163
5074 Node: Variadic Macros
\x7f59277
5075 Node: Predefined Macros
\x7f64059
5076 Node: Standard Predefined Macros
\x7f64642
5077 Node: Common Predefined Macros
\x7f70568
5078 Node: System-specific Predefined Macros
\x7f78403
5079 Node: C++ Named Operators
\x7f80415
5080 Node: Undefining and Redefining Macros
\x7f81370
5081 Node: Directives Within Macro Arguments
\x7f83467
5082 Node: Macro Pitfalls
\x7f85010
5083 Node: Misnesting
\x7f85536
5084 Node: Operator Precedence Problems
\x7f86637
5085 Node: Swallowing the Semicolon
\x7f88492
5086 Node: Duplication of Side Effects
\x7f90504
5087 Node: Self-Referential Macros
\x7f92676
5088 Node: Argument Prescan
\x7f95080
5089 Node: Newlines in Arguments
\x7f98823
5090 Node: Conditionals
\x7f99768
5091 Node: Conditional Uses
\x7f101597
5092 Node: Conditional Syntax
\x7f102950
5093 Node: Ifdef
\x7f103265
5095 Node: Defined
\x7f108732
5096 Node: Else
\x7f110005
5097 Node: Elif
\x7f110566
5098 Node: Deleted Code
\x7f111846
5099 Node: Diagnostics
\x7f113088
5100 Node: Line Control
\x7f114705
5101 Node: Pragmas
\x7f118508
5102 Node: Other Directives
\x7f122776
5103 Node: Preprocessor Output
\x7f123968
5104 Node: Traditional Mode
\x7f127168
5105 Node: Traditional lexical analysis
\x7f128223
5106 Node: Traditional macros
\x7f130719
5107 Node: Traditional miscellany
\x7f134513
5108 Node: Traditional warnings
\x7f135503
5109 Node: Implementation Details
\x7f137693
5110 Node: Implementation-defined behavior
\x7f138311
5111 Ref: Identifier characters
\x7f139041
5112 Node: Implementation limits
\x7f141954
5113 Node: Obsolete Features
\x7f144621
5114 Node: Assertions
\x7f145068
5115 Node: Obsolete once-only headers
\x7f147598
5116 Node: Differences from previous versions
\x7f149322
5117 Node: Invocation
\x7f153394
5118 Ref: Wtrigraphs
\x7f157782
5119 Ref: dashMF
\x7f162566
5120 Ref: fdollars-in-identifiers
\x7f170049
5121 Node: Environment Variables
\x7f177506
5122 Node: GNU Free Documentation License
\x7f180469
5123 Node: Index of Directives
\x7f202899
5124 Node: Option Index
\x7f204279
5125 Node: Concept Index
\x7f208348