1 This is doc/cpp.info, produced by makeinfo version 4.8 from
2 /scratch/mitchell/gcc-releases/gcc-4.0.1/gcc-4.0.1/gcc/doc/cpp.texi.
4 Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
5 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software
8 Permission is granted to copy, distribute and/or modify this document
9 under the terms of the GNU Free Documentation License, Version 1.1 or
10 any later version published by the Free Software Foundation. A copy of
11 the license is included in the section entitled "GNU Free Documentation
14 This manual contains no Invariant Sections. The Front-Cover Texts
15 are (a) (see below), and the Back-Cover Texts are (b) (see below).
17 (a) The FSF's Front-Cover Text is:
21 (b) The FSF's Back-Cover Text is:
23 You have freedom to copy and modify this GNU Manual, like GNU
24 software. Copies published by the Free Software Foundation raise
25 funds for GNU development.
27 INFO-DIR-SECTION Programming
29 * Cpp: (cpp). The GNU C preprocessor.
33 File: cpp.info, Node: Top, Next: Overview, Up: (dir)
38 The C preprocessor implements the macro language used to transform C,
39 C++, and Objective-C programs before they are compiled. It can also be
52 * Preprocessor Output::
54 * Implementation Details::
56 * Environment Variables::
57 * GNU Free Documentation License::
58 * Index of Directives::
62 --- The Detailed Node Listing ---
67 * Initial processing::
69 * The preprocessing language::
83 * Object-like Macros::
84 * Function-like Macros::
90 * Undefining and Redefining Macros::
91 * Directives Within Macro Arguments::
96 * Standard Predefined Macros::
97 * Common Predefined Macros::
98 * System-specific Predefined Macros::
99 * C++ Named Operators::
104 * Operator Precedence Problems::
105 * Swallowing the Semicolon::
106 * Duplication of Side Effects::
107 * Self-Referential Macros::
109 * Newlines in Arguments::
114 * Conditional Syntax::
125 Implementation Details
127 * Implementation-defined behavior::
128 * Implementation limits::
129 * Obsolete Features::
130 * Differences from previous versions::
135 * Obsolete once-only headers::
137 Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
138 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software
141 Permission is granted to copy, distribute and/or modify this document
142 under the terms of the GNU Free Documentation License, Version 1.1 or
143 any later version published by the Free Software Foundation. A copy of
144 the license is included in the section entitled "GNU Free Documentation
147 This manual contains no Invariant Sections. The Front-Cover Texts
148 are (a) (see below), and the Back-Cover Texts are (b) (see below).
150 (a) The FSF's Front-Cover Text is:
154 (b) The FSF's Back-Cover Text is:
156 You have freedom to copy and modify this GNU Manual, like GNU
157 software. Copies published by the Free Software Foundation raise
158 funds for GNU development.
161 File: cpp.info, Node: Overview, Next: Header Files, Prev: Top, Up: Top
166 The C preprocessor, often known as "cpp", is a "macro processor" that
167 is used automatically by the C compiler to transform your program
168 before compilation. It is called a macro processor because it allows
169 you to define "macros", which are brief abbreviations for longer
172 The C preprocessor is intended to be used only with C, C++, and
173 Objective-C source code. In the past, it has been abused as a general
174 text processor. It will choke on input which does not obey C's lexical
175 rules. For example, apostrophes will be interpreted as the beginning of
176 character constants, and cause errors. Also, you cannot rely on it
177 preserving characteristics of the input which are not significant to
178 C-family languages. If a Makefile is preprocessed, all the hard tabs
179 will be removed, and the Makefile will not work.
181 Having said that, you can often get away with using cpp on things
182 which are not C. Other Algol-ish programming languages are often safe
183 (Pascal, Ada, etc.) So is assembly, with caution. `-traditional-cpp'
184 mode preserves more white space, and is otherwise more permissive. Many
185 of the problems can be avoided by writing C or C++ style comments
186 instead of native language comments, and keeping macros simple.
188 Wherever possible, you should use a preprocessor geared to the
189 language you are writing in. Modern versions of the GNU assembler have
190 macro facilities. Most high level programming languages have their own
191 conditional compilation and inclusion mechanism. If all else fails,
192 try a true general text processor, such as GNU M4.
194 C preprocessors vary in some details. This manual discusses the GNU
195 C preprocessor, which provides a small superset of the features of ISO
196 Standard C. In its default mode, the GNU C preprocessor does not do a
197 few things required by the standard. These are features which are
198 rarely, if ever, used, and may cause surprising changes to the meaning
199 of a program which does not expect them. To get strict ISO Standard C,
200 you should use the `-std=c89' or `-std=c99' options, depending on which
201 version of the standard you want. To get all the mandatory
202 diagnostics, you must also use `-pedantic'. *Note Invocation::.
204 This manual describes the behavior of the ISO preprocessor. To
205 minimize gratuitous differences, where the ISO preprocessor's behavior
206 does not conflict with traditional semantics, the traditional
207 preprocessor should behave the same way. The various differences that
208 do exist are detailed in the section *Note Traditional Mode::.
210 For clarity, unless noted otherwise, references to `CPP' in this
211 manual refer to GNU CPP.
216 * Initial processing::
218 * The preprocessing language::
221 File: cpp.info, Node: Character sets, Next: Initial processing, Up: Overview
226 Source code character set processing in C and related languages is
227 rather complicated. The C standard discusses two character sets, but
228 there are really at least four.
230 The files input to CPP might be in any character set at all. CPP's
231 very first action, before it even looks for line boundaries, is to
232 convert the file into the character set it uses for internal
233 processing. That set is what the C standard calls the "source"
234 character set. It must be isomorphic with ISO 10646, also known as
235 Unicode. CPP uses the UTF-8 encoding of Unicode.
237 At present, GNU CPP does not implement conversion from arbitrary file
238 encodings to the source character set. Use of any encoding other than
239 plain ASCII or UTF-8, except in comments, will cause errors. Use of
240 encodings that are not strict supersets of ASCII, such as Shift JIS,
241 may cause errors even if non-ASCII characters appear only in comments.
242 We plan to fix this in the near future.
244 All preprocessing work (the subject of the rest of this manual) is
245 carried out in the source character set. If you request textual output
246 from the preprocessor with the `-E' option, it will be in UTF-8.
248 After preprocessing is complete, string and character constants are
249 converted again, into the "execution" character set. This character
250 set is under control of the user; the default is UTF-8, matching the
251 source character set. Wide string and character constants have their
252 own character set, which is not called out specifically in the
253 standard. Again, it is under control of the user. The default is
254 UTF-16 or UTF-32, whichever fits in the target's `wchar_t' type, in the
255 target machine's byte order.(1) Octal and hexadecimal escape sequences
256 do not undergo conversion; '\x12' has the value 0x12 regardless of the
257 currently selected execution character set. All other escapes are
258 replaced by the character in the source character set that they
259 represent, then converted to the execution character set, just like
260 unescaped characters.
262 GCC does not permit the use of characters outside the ASCII range,
263 nor `\u' and `\U' escapes, in identifiers. We hope this will change
264 eventually, but there are problems with the standard semantics of such
265 "extended identifiers" which must be resolved through the ISO C and C++
268 ---------- Footnotes ----------
270 (1) UTF-16 does not meet the requirements of the C standard for a
271 wide character set, but the choice of 16-bit `wchar_t' is enshrined in
272 some system ABIs so we cannot fix this.
275 File: cpp.info, Node: Initial processing, Next: Tokenization, Prev: Character sets, Up: Overview
277 1.2 Initial processing
278 ======================
280 The preprocessor performs a series of textual transformations on its
281 input. These happen before all other processing. Conceptually, they
282 happen in a rigid order, and the entire file is run through each
283 transformation before the next one begins. CPP actually does them all
284 at once, for performance reasons. These transformations correspond
285 roughly to the first three "phases of translation" described in the C
288 1. The input file is read into memory and broken into lines.
290 Different systems use different conventions to indicate the end of
291 a line. GCC accepts the ASCII control sequences `LF', `CR LF' and
292 `CR' as end-of-line markers. These are the canonical sequences
293 used by Unix, DOS and VMS, and the classic Mac OS (before OSX)
294 respectively. You may therefore safely copy source code written
295 on any of those systems to a different one and use it without
296 conversion. (GCC may lose track of the current line number if a
297 file doesn't consistently use one convention, as sometimes happens
298 when it is edited on computers with different conventions that
299 share a network file system.)
301 If the last line of any input file lacks an end-of-line marker,
302 the end of the file is considered to implicitly supply one. The C
303 standard says that this condition provokes undefined behavior, so
304 GCC will emit a warning message.
306 2. If trigraphs are enabled, they are replaced by their corresponding
307 single characters. By default GCC ignores trigraphs, but if you
308 request a strictly conforming mode with the `-std' option, or you
309 specify the `-trigraphs' option, then it converts them.
311 These are nine three-character sequences, all starting with `??',
312 that are defined by ISO C to stand for single characters. They
313 permit obsolete systems that lack some of C's punctuation to use
314 C. For example, `??/' stands for `\', so '??/n' is a character
315 constant for a newline.
317 Trigraphs are not popular and many compilers implement them
318 incorrectly. Portable code should not rely on trigraphs being
319 either converted or ignored. With `-Wtrigraphs' GCC will warn you
320 when a trigraph may change the meaning of your program if it were
321 converted. *Note Wtrigraphs::.
323 In a string constant, you can prevent a sequence of question marks
324 from being confused with a trigraph by inserting a backslash
325 between the question marks, or by separating the string literal at
326 the trigraph and making use of string literal concatenation.
327 "(??\?)" is the string `(???)', not `(?]'. Traditional C
328 compilers do not recognize these idioms.
330 The nine trigraphs and their replacements are
332 Trigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??-
333 Replacement: [ ] { } # \ ^ | ~
335 3. Continued lines are merged into one long line.
337 A continued line is a line which ends with a backslash, `\'. The
338 backslash is removed and the following line is joined with the
339 current one. No space is inserted, so you may split a line
340 anywhere, even in the middle of a word. (It is generally more
341 readable to split lines only at white space.)
343 The trailing backslash on a continued line is commonly referred to
344 as a "backslash-newline".
346 If there is white space between a backslash and the end of a line,
347 that is still a continued line. However, as this is usually the
348 result of an editing mistake, and many compilers will not accept
349 it as a continued line, GCC will warn you about it.
351 4. All comments are replaced with single spaces.
353 There are two kinds of comments. "Block comments" begin with `/*'
354 and continue until the next `*/'. Block comments do not nest:
356 /* this is /* one comment */ text outside comment
358 "Line comments" begin with `//' and continue to the end of the
359 current line. Line comments do not nest either, but it does not
360 matter, because they would end in the same place anyway.
362 // this is // one comment
365 It is safe to put line comments inside block comments, or vice versa.
368 // contains line comment
372 // line comment /* contains block comment */
374 But beware of commenting out one end of a block comment with a line
377 // l.c. /* block comment begins
378 oops! this isn't a comment anymore */
380 Comments are not recognized within string literals. "/* blah */" is
381 the string constant `/* blah */', not an empty string.
383 Line comments are not in the 1989 edition of the C standard, but they
384 are recognized by GCC as an extension. In C++ and in the 1999 edition
385 of the C standard, they are an official part of the language.
387 Since these transformations happen before all other processing, you
388 can split a line mechanically with backslash-newline anywhere. You can
389 comment out the end of a line. You can continue a line comment onto the
390 next line with backslash-newline. You can even split `/*', `*/', and
391 `//' onto multiple lines with backslash-newline. For example:
401 is equivalent to `#define FOO 1020'. All these tricks are extremely
402 confusing and should not be used in code intended to be readable.
404 There is no way to prevent a backslash at the end of a line from
405 being interpreted as a backslash-newline. This cannot affect any
406 correct program, however.
409 File: cpp.info, Node: Tokenization, Next: The preprocessing language, Prev: Initial processing, Up: Overview
414 After the textual transformations are finished, the input file is
415 converted into a sequence of "preprocessing tokens". These mostly
416 correspond to the syntactic tokens used by the C compiler, but there are
417 a few differences. White space separates tokens; it is not itself a
418 token of any kind. Tokens do not have to be separated by white space,
419 but it is often necessary to avoid ambiguities.
421 When faced with a sequence of characters that has more than one
422 possible tokenization, the preprocessor is greedy. It always makes
423 each token, starting from the left, as big as possible before moving on
424 to the next token. For instance, `a+++++b' is interpreted as
425 `a ++ ++ + b', not as `a ++ + ++ b', even though the latter
426 tokenization could be part of a valid C program and the former could
429 Once the input file is broken into tokens, the token boundaries never
430 change, except when the `##' preprocessing operator is used to paste
431 tokens together. *Note Concatenation::. For example,
439 The compiler does not re-tokenize the preprocessor's output. Each
440 preprocessing token becomes one compiler token.
442 Preprocessing tokens fall into five broad classes: identifiers,
443 preprocessing numbers, string literals, punctuators, and other. An
444 "identifier" is the same as an identifier in C: any sequence of
445 letters, digits, or underscores, which begins with a letter or
446 underscore. Keywords of C have no significance to the preprocessor;
447 they are ordinary identifiers. You can define a macro whose name is a
448 keyword, for instance. The only identifier which can be considered a
449 preprocessing keyword is `defined'. *Note Defined::.
451 This is mostly true of other languages which use the C preprocessor.
452 However, a few of the keywords of C++ are significant even in the
453 preprocessor. *Note C++ Named Operators::.
455 In the 1999 C standard, identifiers may contain letters which are not
456 part of the "basic source character set", at the implementation's
457 discretion (such as accented Latin letters, Greek letters, or Chinese
458 ideograms). This may be done with an extended character set, or the
459 `\u' and `\U' escape sequences. GCC does not presently implement
460 either feature in the preprocessor or the compiler.
462 As an extension, GCC treats `$' as a letter. This is for
463 compatibility with some systems, such as VMS, where `$' is commonly
464 used in system-defined function and object names. `$' is not a letter
465 in strictly conforming mode, or if you specify the `-$' option. *Note
468 A "preprocessing number" has a rather bizarre definition. The
469 category includes all the normal integer and floating point constants
470 one expects of C, but also a number of other things one might not
471 initially recognize as a number. Formally, preprocessing numbers begin
472 with an optional period, a required decimal digit, and then continue
473 with any sequence of letters, digits, underscores, periods, and
474 exponents. Exponents are the two-character sequences `e+', `e-', `E+',
475 `E-', `p+', `p-', `P+', and `P-'. (The exponents that begin with `p'
476 or `P' are new to C99. They are used for hexadecimal floating-point
479 The purpose of this unusual definition is to isolate the preprocessor
480 from the full complexity of numeric constants. It does not have to
481 distinguish between lexically valid and invalid floating-point numbers,
482 which is complicated. The definition also permits you to split an
483 identifier at any position and get exactly two tokens, which can then be
484 pasted back together with the `##' operator.
486 It's possible for preprocessing numbers to cause programs to be
487 misinterpreted. For example, `0xE+12' is a preprocessing number which
488 does not translate to any valid numeric constant, therefore a syntax
489 error. It does not mean `0xE + 12', which is what you might have
492 "String literals" are string constants, character constants, and
493 header file names (the argument of `#include').(1) String constants
494 and character constants are straightforward: "..." or '...'. In either
495 case embedded quotes should be escaped with a backslash: '\'' is the
496 character constant for `''. There is no limit on the length of a
497 character constant, but the value of a character constant that contains
498 more than one character is implementation-defined. *Note
499 Implementation Details::.
501 Header file names either look like string constants, "...", or are
502 written with angle brackets instead, <...>. In either case, backslash
503 is an ordinary character. There is no way to escape the closing quote
504 or angle bracket. The preprocessor looks for the header file in
505 different places depending on which form you use. *Note Include
508 No string literal may extend past the end of a line. Older versions
509 of GCC accepted multi-line string constants. You may use continued
510 lines instead, or string constant concatenation. *Note Differences
511 from previous versions::.
513 "Punctuators" are all the usual bits of punctuation which are
514 meaningful to C and C++. All but three of the punctuation characters in
515 ASCII are C punctuators. The exceptions are `@', `$', and ``'. In
516 addition, all the two- and three-character operators are punctuators.
517 There are also six "digraphs", which the C++ standard calls
518 "alternative tokens", which are merely alternate ways to spell other
519 punctuators. This is a second attempt to work around missing
520 punctuation in obsolete systems. It has no negative side effects,
521 unlike trigraphs, but does not cover as much ground. The digraphs and
522 their corresponding normal punctuators are:
524 Digraph: <% %> <: :> %: %:%:
525 Punctuator: { } [ ] # ##
527 Any other single character is considered "other". It is passed on to
528 the preprocessor's output unmolested. The C compiler will almost
529 certainly reject source code containing "other" tokens. In ASCII, the
530 only other characters are `@', `$', ``', and control characters other
531 than NUL (all bits zero). (Note that `$' is normally considered a
532 letter.) All characters with the high bit set (numeric range
533 0x7F-0xFF) are also "other" in the present implementation. This will
534 change when proper support for international character sets is added to
537 NUL is a special case because of the high probability that its
538 appearance is accidental, and because it may be invisible to the user
539 (many terminals do not display NUL at all). Within comments, NULs are
540 silently ignored, just as any other character would be. In running
541 text, NUL is considered white space. For example, these two directives
542 have the same meaning.
547 (where `^@' is ASCII NUL). Within string or character constants, NULs
548 are preserved. In the latter two cases the preprocessor emits a
551 ---------- Footnotes ----------
553 (1) The C standard uses the term "string literal" to refer only to
554 what we are calling "string constants".
557 File: cpp.info, Node: The preprocessing language, Prev: Tokenization, Up: Overview
559 1.4 The preprocessing language
560 ==============================
562 After tokenization, the stream of tokens may simply be passed straight
563 to the compiler's parser. However, if it contains any operations in the
564 "preprocessing language", it will be transformed first. This stage
565 corresponds roughly to the standard's "translation phase 4" and is what
566 most people think of as the preprocessor's job.
568 The preprocessing language consists of "directives" to be executed
569 and "macros" to be expanded. Its primary capabilities are:
571 * Inclusion of header files. These are files of declarations that
572 can be substituted into your program.
574 * Macro expansion. You can define "macros", which are abbreviations
575 for arbitrary fragments of C code. The preprocessor will replace
576 the macros with their definitions throughout the program. Some
577 macros are automatically defined for you.
579 * Conditional compilation. You can include or exclude parts of the
580 program according to various conditions.
582 * Line control. If you use a program to combine or rearrange source
583 files into an intermediate file which is then compiled, you can
584 use line control to inform the compiler where each source line
585 originally came from.
587 * Diagnostics. You can detect problems at compile time and issue
590 There are a few more, less useful, features.
592 Except for expansion of predefined macros, all these operations are
593 triggered with "preprocessing directives". Preprocessing directives
594 are lines in your program that start with `#'. Whitespace is allowed
595 before and after the `#'. The `#' is followed by an identifier, the
596 "directive name". It specifies the operation to perform. Directives
597 are commonly referred to as `#NAME' where NAME is the directive name.
598 For example, `#define' is the directive that defines a macro.
600 The `#' which begins a directive cannot come from a macro expansion.
601 Also, the directive name is not macro expanded. Thus, if `foo' is
602 defined as a macro expanding to `define', that does not make `#foo' a
603 valid preprocessing directive.
605 The set of valid directive names is fixed. Programs cannot define
606 new preprocessing directives.
608 Some directives require arguments; these make up the rest of the
609 directive line and must be separated from the directive name by
610 whitespace. For example, `#define' must be followed by a macro name
611 and the intended expansion of the macro.
613 A preprocessing directive cannot cover more than one line. The line
614 may, however, be continued with backslash-newline, or by a block comment
615 which extends past the end of the line. In either case, when the
616 directive is processed, the continuations have already been merged with
617 the first line to make one long line.
620 File: cpp.info, Node: Header Files, Next: Macros, Prev: Overview, Up: Top
625 A header file is a file containing C declarations and macro definitions
626 (*note Macros::) to be shared between several source files. You request
627 the use of a header file in your program by "including" it, with the C
628 preprocessing directive `#include'.
630 Header files serve two purposes.
632 * System header files declare the interfaces to parts of the
633 operating system. You include them in your program to supply the
634 definitions and declarations you need to invoke system calls and
637 * Your own header files contain declarations for interfaces between
638 the source files of your program. Each time you have a group of
639 related declarations and macro definitions all or most of which
640 are needed in several different source files, it is a good idea to
641 create a header file for them.
643 Including a header file produces the same results as copying the
644 header file into each source file that needs it. Such copying would be
645 time-consuming and error-prone. With a header file, the related
646 declarations appear in only one place. If they need to be changed, they
647 can be changed in one place, and programs that include the header file
648 will automatically use the new version when next recompiled. The header
649 file eliminates the labor of finding and changing all the copies as well
650 as the risk that a failure to find one copy will result in
651 inconsistencies within a program.
653 In C, the usual convention is to give header files names that end
654 with `.h'. It is most portable to use only letters, digits, dashes, and
655 underscores in header file names, and at most one dot.
660 * Include Operation::
662 * Once-Only Headers::
663 * Computed Includes::
668 File: cpp.info, Node: Include Syntax, Next: Include Operation, Up: Header Files
673 Both user and system header files are included using the preprocessing
674 directive `#include'. It has two variants:
677 This variant is used for system header files. It searches for a
678 file named FILE in a standard list of system directories. You can
679 prepend directories to this list with the `-I' option (*note
683 This variant is used for header files of your own program. It
684 searches for a file named FILE first in the directory containing
685 the current file, then in the quote directories and then the same
686 directories used for `<FILE>'. You can prepend directories to the
687 list of quote directories with the `-iquote' option.
689 The argument of `#include', whether delimited with quote marks or
690 angle brackets, behaves like a string constant in that comments are not
691 recognized, and macro names are not expanded. Thus, `#include <x/*y>'
692 specifies inclusion of a system header file named `x/*y'.
694 However, if backslashes occur within FILE, they are considered
695 ordinary text characters, not escape characters. None of the character
696 escape sequences appropriate to string constants in C are processed.
697 Thus, `#include "x\n\\y"' specifies a filename containing three
698 backslashes. (Some systems interpret `\' as a pathname separator. All
699 of these also interpret `/' the same way. It is most portable to use
702 It is an error if there is anything (other than comments) on the line
706 File: cpp.info, Node: Include Operation, Next: Search Path, Prev: Include Syntax, Up: Header Files
708 2.2 Include Operation
709 =====================
711 The `#include' directive works by directing the C preprocessor to scan
712 the specified file as input before continuing with the rest of the
713 current file. The output from the preprocessor contains the output
714 already generated, followed by the output resulting from the included
715 file, followed by the output that comes from the text after the
716 `#include' directive. For example, if you have a header file
717 `header.h' as follows,
721 and a main program called `program.c' that uses the header file, like
733 the compiler will see the same token stream as it would if `program.c'
745 Included files are not limited to declarations and macro definitions;
746 those are merely the typical uses. Any fragment of a C program can be
747 included from another file. The include file could even contain the
748 beginning of a statement that is concluded in the containing file, or
749 the end of a statement that was started in the including file. However,
750 an included file must consist of complete tokens. Comments and string
751 literals which have not been closed by the end of an included file are
752 invalid. For error recovery, they are considered to end at the end of
755 To avoid confusion, it is best if header files contain only complete
756 syntactic units--function declarations or definitions, type
759 The line following the `#include' directive is always treated as a
760 separate line by the C preprocessor, even if the included file lacks a
764 File: cpp.info, Node: Search Path, Next: Once-Only Headers, Prev: Include Operation, Up: Header Files
769 GCC looks in several different places for headers. On a normal Unix
770 system, if you do not instruct it otherwise, it will look for headers
771 requested with `#include <FILE>' in:
774 LIBDIR/gcc/TARGET/VERSION/include
778 For C++ programs, it will also look in `/usr/include/g++-v3', first.
779 In the above, TARGET is the canonical name of the system GCC was
780 configured to compile code for; often but not always the same as the
781 canonical name of the system it runs on. VERSION is the version of GCC
784 You can add to this list with the `-IDIR' command line option. All
785 the directories named by `-I' are searched, in left-to-right order,
786 _before_ the default directories. The only exception is when `dir' is
787 already searched by default. In this case, the option is ignored and
788 the search order for system directories remains unchanged.
790 Duplicate directories are removed from the quote and bracket search
791 chains before the two chains are merged to make the final search chain.
792 Thus, it is possible for a directory to occur twice in the final search
793 chain if it was specified in both the quote and bracket chains.
795 You can prevent GCC from searching any of the default directories
796 with the `-nostdinc' option. This is useful when you are compiling an
797 operating system kernel or some other program that does not use the
798 standard C library facilities, or the standard C library itself. `-I'
799 options are not ignored as described above when `-nostdinc' is in
802 GCC looks for headers requested with `#include "FILE"' first in the
803 directory containing the current file, then in the directories as
804 specified by `-iquote' options, then in the same places it would have
805 looked for a header requested with angle brackets. For example, if
806 `/usr/include/sys/stat.h' contains `#include "types.h"', GCC looks for
807 `types.h' first in `/usr/include/sys', then in its usual search path.
809 `#line' (*note Line Control::) does not change GCC's idea of the
810 directory containing the current file.
812 You may put `-I-' at any point in your list of `-I' options. This
813 has two effects. First, directories appearing before the `-I-' in the
814 list are searched only for headers requested with quote marks.
815 Directories after `-I-' are searched for all headers. Second, the
816 directory containing the current file is not searched for anything,
817 unless it happens to be one of the directories named by an `-I' switch.
818 `-I-' is deprecated, `-iquote' should be used instead.
820 `-I. -I-' is not the same as no `-I' options at all, and does not
821 cause the same behavior for `<>' includes that `""' includes get with
822 no special options. `-I.' searches the compiler's current working
823 directory for header files. That may or may not be the same as the
824 directory containing the current file.
826 If you need to look for headers in a directory named `-', write
829 There are several more ways to adjust the header search path. They
830 are generally less useful. *Note Invocation::.
833 File: cpp.info, Node: Once-Only Headers, Next: Computed Includes, Prev: Search Path, Up: Header Files
835 2.4 Once-Only Headers
836 =====================
838 If a header file happens to be included twice, the compiler will process
839 its contents twice. This is very likely to cause an error, e.g. when
840 the compiler sees the same structure definition twice. Even if it does
841 not, it will certainly waste time.
843 The standard way to prevent this is to enclose the entire real
844 contents of the file in a conditional, like this:
847 #ifndef FILE_FOO_SEEN
848 #define FILE_FOO_SEEN
852 #endif /* !FILE_FOO_SEEN */
854 This construct is commonly known as a "wrapper #ifndef". When the
855 header is included again, the conditional will be false, because
856 `FILE_FOO_SEEN' is defined. The preprocessor will skip over the entire
857 contents of the file, and the compiler will not see it twice.
859 CPP optimizes even further. It remembers when a header file has a
860 wrapper `#ifndef'. If a subsequent `#include' specifies that header,
861 and the macro in the `#ifndef' is still defined, it does not bother to
862 rescan the file at all.
864 You can put comments outside the wrapper. They will not interfere
865 with this optimization.
867 The macro `FILE_FOO_SEEN' is called the "controlling macro" or
868 "guard macro". In a user header file, the macro name should not begin
869 with `_'. In a system header file, it should begin with `__' to avoid
870 conflicts with user programs. In any kind of header file, the macro
871 name should contain the name of the file and some additional text, to
872 avoid conflicts with other header files.
875 File: cpp.info, Node: Computed Includes, Next: Wrapper Headers, Prev: Once-Only Headers, Up: Header Files
877 2.5 Computed Includes
878 =====================
880 Sometimes it is necessary to select one of several different header
881 files to be included into your program. They might specify
882 configuration parameters to be used on different sorts of operating
883 systems, for instance. You could do this with a series of conditionals,
886 # include "system_1.h"
888 # include "system_2.h"
893 That rapidly becomes tedious. Instead, the preprocessor offers the
894 ability to use a macro for the header name. This is called a "computed
895 include". Instead of writing a header name as the direct argument of
896 `#include', you simply put a macro name there instead:
898 #define SYSTEM_H "system_1.h"
902 `SYSTEM_H' will be expanded, and the preprocessor will look for
903 `system_1.h' as if the `#include' had been written that way originally.
904 `SYSTEM_H' could be defined by your Makefile with a `-D' option.
906 You must be careful when you define the macro. `#define' saves
907 tokens, not text. The preprocessor has no way of knowing that the macro
908 will be used as the argument of `#include', so it generates ordinary
909 tokens, not a header name. This is unlikely to cause problems if you
910 use double-quote includes, which are close enough to string constants.
911 If you use angle brackets, however, you may have trouble.
913 The syntax of a computed include is actually a bit more general than
914 the above. If the first non-whitespace character after `#include' is
915 not `"' or `<', then the entire line is macro-expanded like running
918 If the line expands to a single string constant, the contents of that
919 string constant are the file to be included. CPP does not re-examine
920 the string for embedded quotes, but neither does it process backslash
921 escapes in the string. Therefore
923 #define HEADER "a\"b"
926 looks for a file named `a\"b'. CPP searches for the file according to
927 the rules for double-quoted includes.
929 If the line expands to a token stream beginning with a `<' token and
930 including a `>' token, then the tokens between the `<' and the first
931 `>' are combined to form the filename to be included. Any whitespace
932 between tokens is reduced to a single space; then any space after the
933 initial `<' is retained, but a trailing space before the closing `>' is
934 ignored. CPP searches for the file according to the rules for
935 angle-bracket includes.
937 In either case, if there are any tokens on the line after the file
938 name, an error occurs and the directive is not processed. It is also
939 an error if the result of expansion does not match either of the two
942 These rules are implementation-defined behavior according to the C
943 standard. To minimize the risk of different compilers interpreting your
944 computed includes differently, we recommend you use only a single
945 object-like macro which expands to a string constant. This will also
946 minimize confusion for people reading your program.
949 File: cpp.info, Node: Wrapper Headers, Next: System Headers, Prev: Computed Includes, Up: Header Files
954 Sometimes it is necessary to adjust the contents of a system-provided
955 header file without editing it directly. GCC's `fixincludes' operation
956 does this, for example. One way to do that would be to create a new
957 header file with the same name and insert it in the search path before
958 the original header. That works fine as long as you're willing to
959 replace the old header entirely. But what if you want to refer to the
960 old header from the new one?
962 You cannot simply include the old header with `#include'. That will
963 start from the beginning, and find your new header again. If your
964 header is not protected from multiple inclusion (*note Once-Only
965 Headers::), it will recurse infinitely and cause a fatal error.
967 You could include the old header with an absolute pathname:
968 #include "/usr/include/old-header.h"
969 This works, but is not clean; should the system headers ever move,
970 you would have to edit the new headers to match.
972 There is no way to solve this problem within the C standard, but you
973 can use the GNU extension `#include_next'. It means, "Include the
974 _next_ file with this name". This directive works like `#include'
975 except in searching for the specified file: it starts searching the
976 list of header file directories _after_ the directory in which the
977 current file was found.
979 Suppose you specify `-I /usr/local/include', and the list of
980 directories to search also includes `/usr/include'; and suppose both
981 directories contain `signal.h'. Ordinary `#include <signal.h>' finds
982 the file under `/usr/local/include'. If that file contains
983 `#include_next <signal.h>', it starts searching after that directory,
984 and finds the file in `/usr/include'.
986 `#include_next' does not distinguish between `<FILE>' and `"FILE"'
987 inclusion, nor does it check that the file you specify has the same
988 name as the current file. It simply looks for the file named, starting
989 with the directory in the search path after the one where the current
992 The use of `#include_next' can lead to great confusion. We
993 recommend it be used only when there is no other alternative. In
994 particular, it should not be used in the headers belonging to a specific
995 program; it should be used only to make global corrections along the
996 lines of `fixincludes'.
999 File: cpp.info, Node: System Headers, Prev: Wrapper Headers, Up: Header Files
1004 The header files declaring interfaces to the operating system and
1005 runtime libraries often cannot be written in strictly conforming C.
1006 Therefore, GCC gives code found in "system headers" special treatment.
1007 All warnings, other than those generated by `#warning' (*note
1008 Diagnostics::), are suppressed while GCC is processing a system header.
1009 Macros defined in a system header are immune to a few warnings
1010 wherever they are expanded. This immunity is granted on an ad-hoc
1011 basis, when we find that a warning generates lots of false positives
1012 because of code in macros defined in system headers.
1014 Normally, only the headers found in specific directories are
1015 considered system headers. These directories are determined when GCC
1016 is compiled. There are, however, two ways to make normal headers into
1019 The `-isystem' command line option adds its argument to the list of
1020 directories to search for headers, just like `-I'. Any headers found
1021 in that directory will be considered system headers.
1023 All directories named by `-isystem' are searched _after_ all
1024 directories named by `-I', no matter what their order was on the
1025 command line. If the same directory is named by both `-I' and
1026 `-isystem', the `-I' option is ignored. GCC provides an informative
1027 message when this occurs if `-v' is used.
1029 There is also a directive, `#pragma GCC system_header', which tells
1030 GCC to consider the rest of the current include file a system header,
1031 no matter where it was found. Code that comes before the `#pragma' in
1032 the file will not be affected. `#pragma GCC system_header' has no
1033 effect in the primary source file.
1035 On very old systems, some of the pre-defined system header
1036 directories get even more special treatment. GNU C++ considers code in
1037 headers found in those directories to be surrounded by an `extern "C"'
1038 block. There is no way to request this behavior with a `#pragma', or
1039 from the command line.
1042 File: cpp.info, Node: Macros, Next: Conditionals, Prev: Header Files, Up: Top
1047 A "macro" is a fragment of code which has been given a name. Whenever
1048 the name is used, it is replaced by the contents of the macro. There
1049 are two kinds of macros. They differ mostly in what they look like
1050 when they are used. "Object-like" macros resemble data objects when
1051 used, "function-like" macros resemble function calls.
1053 You may define any valid identifier as a macro, even if it is a C
1054 keyword. The preprocessor does not know anything about keywords. This
1055 can be useful if you wish to hide a keyword such as `const' from an
1056 older compiler that does not understand it. However, the preprocessor
1057 operator `defined' (*note Defined::) can never be defined as a macro,
1058 and C++'s named operators (*note C++ Named Operators::) cannot be
1059 macros when you are compiling C++.
1063 * Object-like Macros::
1064 * Function-like Macros::
1069 * Predefined Macros::
1070 * Undefining and Redefining Macros::
1071 * Directives Within Macro Arguments::
1075 File: cpp.info, Node: Object-like Macros, Next: Function-like Macros, Up: Macros
1077 3.1 Object-like Macros
1078 ======================
1080 An "object-like macro" is a simple identifier which will be replaced by
1081 a code fragment. It is called object-like because it looks like a data
1082 object in code that uses it. They are most commonly used to give
1083 symbolic names to numeric constants.
1085 You create macros with the `#define' directive. `#define' is
1086 followed by the name of the macro and then the token sequence it should
1087 be an abbreviation for, which is variously referred to as the macro's
1088 "body", "expansion" or "replacement list". For example,
1090 #define BUFFER_SIZE 1024
1092 defines a macro named `BUFFER_SIZE' as an abbreviation for the token
1093 `1024'. If somewhere after this `#define' directive there comes a C
1094 statement of the form
1096 foo = (char *) malloc (BUFFER_SIZE);
1098 then the C preprocessor will recognize and "expand" the macro
1099 `BUFFER_SIZE'. The C compiler will see the same tokens as it would if
1102 foo = (char *) malloc (1024);
1104 By convention, macro names are written in uppercase. Programs are
1105 easier to read when it is possible to tell at a glance which names are
1108 The macro's body ends at the end of the `#define' line. You may
1109 continue the definition onto multiple lines, if necessary, using
1110 backslash-newline. When the macro is expanded, however, it will all
1111 come out on one line. For example,
1113 #define NUMBERS 1, \
1116 int x[] = { NUMBERS };
1117 ==> int x[] = { 1, 2, 3 };
1119 The most common visible consequence of this is surprising line numbers
1122 There is no restriction on what can go in a macro body provided it
1123 decomposes into valid preprocessing tokens. Parentheses need not
1124 balance, and the body need not resemble valid C code. (If it does not,
1125 you may get error messages from the C compiler when you use the macro.)
1127 The C preprocessor scans your program sequentially. Macro
1128 definitions take effect at the place you write them. Therefore, the
1129 following input to the C preprocessor
1140 When the preprocessor expands a macro name, the macro's expansion
1141 replaces the macro invocation, then the expansion is examined for more
1142 macros to expand. For example,
1144 #define TABLESIZE BUFSIZE
1145 #define BUFSIZE 1024
1150 `TABLESIZE' is expanded first to produce `BUFSIZE', then that macro is
1151 expanded to produce the final result, `1024'.
1153 Notice that `BUFSIZE' was not defined when `TABLESIZE' was defined.
1154 The `#define' for `TABLESIZE' uses exactly the expansion you
1155 specify--in this case, `BUFSIZE'--and does not check to see whether it
1156 too contains macro names. Only when you _use_ `TABLESIZE' is the
1157 result of its expansion scanned for more macro names.
1159 This makes a difference if you change the definition of `BUFSIZE' at
1160 some point in the source file. `TABLESIZE', defined as shown, will
1161 always expand using the definition of `BUFSIZE' that is currently in
1164 #define BUFSIZE 1020
1165 #define TABLESIZE BUFSIZE
1169 Now `TABLESIZE' expands (in two stages) to `37'.
1171 If the expansion of a macro contains its own name, either directly or
1172 via intermediate macros, it is not expanded again when the expansion is
1173 examined for more macros. This prevents infinite recursion. *Note
1174 Self-Referential Macros::, for the precise details.
1177 File: cpp.info, Node: Function-like Macros, Next: Macro Arguments, Prev: Object-like Macros, Up: Macros
1179 3.2 Function-like Macros
1180 ========================
1182 You can also define macros whose use looks like a function call. These
1183 are called "function-like macros". To define a function-like macro,
1184 you use the same `#define' directive, but you put a pair of parentheses
1185 immediately after the macro name. For example,
1187 #define lang_init() c_init()
1191 A function-like macro is only expanded if its name appears with a
1192 pair of parentheses after it. If you write just the name, it is left
1193 alone. This can be useful when you have a function and a macro of the
1194 same name, and you wish to use the function sometimes.
1196 extern void foo(void);
1197 #define foo() /* optimized inline version */
1202 Here the call to `foo()' will use the macro, but the function
1203 pointer will get the address of the real function. If the macro were to
1204 be expanded, it would cause a syntax error.
1206 If you put spaces between the macro name and the parentheses in the
1207 macro definition, that does not define a function-like macro, it defines
1208 an object-like macro whose expansion happens to begin with a pair of
1211 #define lang_init () c_init()
1215 The first two pairs of parentheses in this expansion come from the
1216 macro. The third is the pair that was originally after the macro
1217 invocation. Since `lang_init' is an object-like macro, it does not
1218 consume those parentheses.
1221 File: cpp.info, Node: Macro Arguments, Next: Stringification, Prev: Function-like Macros, Up: Macros
1226 Function-like macros can take "arguments", just like true functions.
1227 To define a macro that uses arguments, you insert "parameters" between
1228 the pair of parentheses in the macro definition that make the macro
1229 function-like. The parameters must be valid C identifiers, separated
1230 by commas and optionally whitespace.
1232 To invoke a macro that takes arguments, you write the name of the
1233 macro followed by a list of "actual arguments" in parentheses, separated
1234 by commas. The invocation of the macro need not be restricted to a
1235 single logical line--it can cross as many lines in the source file as
1236 you wish. The number of arguments you give must match the number of
1237 parameters in the macro definition. When the macro is expanded, each
1238 use of a parameter in its body is replaced by the tokens of the
1239 corresponding argument. (You need not use all of the parameters in the
1242 As an example, here is a macro that computes the minimum of two
1243 numeric values, as it is defined in many C programs, and some uses.
1245 #define min(X, Y) ((X) < (Y) ? (X) : (Y))
1246 x = min(a, b); ==> x = ((a) < (b) ? (a) : (b));
1247 y = min(1, 2); ==> y = ((1) < (2) ? (1) : (2));
1248 z = min(a + 28, *p); ==> z = ((a + 28) < (*p) ? (a + 28) : (*p));
1250 (In this small example you can already see several of the dangers of
1251 macro arguments. *Note Macro Pitfalls::, for detailed explanations.)
1253 Leading and trailing whitespace in each argument is dropped, and all
1254 whitespace between the tokens of an argument is reduced to a single
1255 space. Parentheses within each argument must balance; a comma within
1256 such parentheses does not end the argument. However, there is no
1257 requirement for square brackets or braces to balance, and they do not
1258 prevent a comma from separating arguments. Thus,
1260 macro (array[x = y, x + 1])
1262 passes two arguments to `macro': `array[x = y' and `x + 1]'. If you
1263 want to supply `array[x = y, x + 1]' as an argument, you can write it
1264 as `array[(x = y, x + 1)]', which is equivalent C code.
1266 All arguments to a macro are completely macro-expanded before they
1267 are substituted into the macro body. After substitution, the complete
1268 text is scanned again for macros to expand, including the arguments.
1269 This rule may seem strange, but it is carefully designed so you need
1270 not worry about whether any function call is actually a macro
1271 invocation. You can run into trouble if you try to be too clever,
1272 though. *Note Argument Prescan::, for detailed discussion.
1274 For example, `min (min (a, b), c)' is first expanded to
1276 min (((a) < (b) ? (a) : (b)), (c))
1280 ((((a) < (b) ? (a) : (b))) < (c)
1281 ? (((a) < (b) ? (a) : (b)))
1284 (Line breaks shown here for clarity would not actually be generated.)
1286 You can leave macro arguments empty; this is not an error to the
1287 preprocessor (but many macros will then expand to invalid code). You
1288 cannot leave out arguments entirely; if a macro takes two arguments,
1289 there must be exactly one comma at the top level of its argument list.
1290 Here are some silly examples using `min':
1292 min(, b) ==> (( ) < (b) ? ( ) : (b))
1293 min(a, ) ==> ((a ) < ( ) ? (a ) : ( ))
1294 min(,) ==> (( ) < ( ) ? ( ) : ( ))
1295 min((,),) ==> (((,)) < ( ) ? ((,)) : ( ))
1297 min() error--> macro "min" requires 2 arguments, but only 1 given
1298 min(,,) error--> macro "min" passed 3 arguments, but takes just 2
1300 Whitespace is not a preprocessing token, so if a macro `foo' takes
1301 one argument, `foo ()' and `foo ( )' both supply it an empty argument.
1302 Previous GNU preprocessor implementations and documentation were
1303 incorrect on this point, insisting that a function-like macro that
1304 takes a single argument be passed a space if an empty argument was
1307 Macro parameters appearing inside string literals are not replaced by
1308 their corresponding actual arguments.
1310 #define foo(x) x, "x"
1311 foo(bar) ==> bar, "x"
1314 File: cpp.info, Node: Stringification, Next: Concatenation, Prev: Macro Arguments, Up: Macros
1319 Sometimes you may want to convert a macro argument into a string
1320 constant. Parameters are not replaced inside string constants, but you
1321 can use the `#' preprocessing operator instead. When a macro parameter
1322 is used with a leading `#', the preprocessor replaces it with the
1323 literal text of the actual argument, converted to a string constant.
1324 Unlike normal parameter replacement, the argument is not macro-expanded
1325 first. This is called "stringification".
1327 There is no way to combine an argument with surrounding text and
1328 stringify it all together. Instead, you can write a series of adjacent
1329 string constants and stringified arguments. The preprocessor will
1330 replace the stringified arguments with string constants. The C
1331 compiler will then combine all the adjacent string constants into one
1334 Here is an example of a macro definition that uses stringification:
1336 #define WARN_IF(EXP) \
1338 fprintf (stderr, "Warning: " #EXP "\n"); } \
1341 ==> do { if (x == 0)
1342 fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0);
1344 The argument for `EXP' is substituted once, as-is, into the `if'
1345 statement, and once, stringified, into the argument to `fprintf'. If
1346 `x' were a macro, it would be expanded in the `if' statement, but not
1349 The `do' and `while (0)' are a kludge to make it possible to write
1350 `WARN_IF (ARG);', which the resemblance of `WARN_IF' to a function
1351 would make C programmers want to do; see *Note Swallowing the
1354 Stringification in C involves more than putting double-quote
1355 characters around the fragment. The preprocessor backslash-escapes the
1356 quotes surrounding embedded string constants, and all backslashes
1357 within string and character constants, in order to get a valid C string
1358 constant with the proper contents. Thus, stringifying `p = "foo\n";'
1359 results in "p = \"foo\\n\";". However, backslashes that are not inside
1360 string or character constants are not duplicated: `\n' by itself
1361 stringifies to "\n".
1363 All leading and trailing whitespace in text being stringified is
1364 ignored. Any sequence of whitespace in the middle of the text is
1365 converted to a single space in the stringified result. Comments are
1366 replaced by whitespace long before stringification happens, so they
1367 never appear in stringified text.
1369 There is no way to convert a macro argument into a character
1372 If you want to stringify the result of expansion of a macro argument,
1373 you have to use two levels of macros.
1375 #define xstr(s) str(s)
1385 `s' is stringified when it is used in `str', so it is not
1386 macro-expanded first. But `s' is an ordinary argument to `xstr', so it
1387 is completely macro-expanded before `xstr' itself is expanded (*note
1388 Argument Prescan::). Therefore, by the time `str' gets to its
1389 argument, it has already been macro-expanded.
1392 File: cpp.info, Node: Concatenation, Next: Variadic Macros, Prev: Stringification, Up: Macros
1397 It is often useful to merge two tokens into one while expanding macros.
1398 This is called "token pasting" or "token concatenation". The `##'
1399 preprocessing operator performs token pasting. When a macro is
1400 expanded, the two tokens on either side of each `##' operator are
1401 combined into a single token, which then replaces the `##' and the two
1402 original tokens in the macro expansion. Usually both will be
1403 identifiers, or one will be an identifier and the other a preprocessing
1404 number. When pasted, they make a longer identifier. This isn't the
1405 only valid case. It is also possible to concatenate two numbers (or a
1406 number and a name, such as `1.5' and `e3') into a number. Also,
1407 multi-character operators such as `+=' can be formed by token pasting.
1409 However, two tokens that don't together form a valid token cannot be
1410 pasted together. For example, you cannot concatenate `x' with `+' in
1411 either order. If you try, the preprocessor issues a warning and emits
1412 the two tokens. Whether it puts white space between the tokens is
1413 undefined. It is common to find unnecessary uses of `##' in complex
1414 macros. If you get this warning, it is likely that you can simply
1417 Both the tokens combined by `##' could come from the macro body, but
1418 you could just as well write them as one token in the first place.
1419 Token pasting is most useful when one or both of the tokens comes from a
1420 macro argument. If either of the tokens next to an `##' is a parameter
1421 name, it is replaced by its actual argument before `##' executes. As
1422 with stringification, the actual argument is not macro-expanded first.
1423 If the argument is empty, that `##' has no effect.
1425 Keep in mind that the C preprocessor converts comments to whitespace
1426 before macros are even considered. Therefore, you cannot create a
1427 comment by concatenating `/' and `*'. You can put as much whitespace
1428 between `##' and its operands as you like, including comments, and you
1429 can put comments in arguments that will be concatenated. However, it
1430 is an error if `##' appears at either end of a macro body.
1432 Consider a C program that interprets named commands. There probably
1433 needs to be a table of commands, perhaps an array of structures declared
1439 void (*function) (void);
1442 struct command commands[] =
1444 { "quit", quit_command },
1445 { "help", help_command },
1449 It would be cleaner not to have to give each command name twice,
1450 once in the string constant and once in the function name. A macro
1451 which takes the name of a command as an argument can make this
1452 unnecessary. The string constant can be created with stringification,
1453 and the function name by concatenating the argument with `_command'.
1454 Here is how it is done:
1456 #define COMMAND(NAME) { #NAME, NAME ## _command }
1458 struct command commands[] =
1466 File: cpp.info, Node: Variadic Macros, Next: Predefined Macros, Prev: Concatenation, Up: Macros
1471 A macro can be declared to accept a variable number of arguments much as
1472 a function can. The syntax for defining the macro is similar to that of
1473 a function. Here is an example:
1475 #define eprintf(...) fprintf (stderr, __VA_ARGS__)
1477 This kind of macro is called "variadic". When the macro is invoked,
1478 all the tokens in its argument list after the last named argument (this
1479 macro has none), including any commas, become the "variable argument".
1480 This sequence of tokens replaces the identifier `__VA_ARGS__' in the
1481 macro body wherever it appears. Thus, we have this expansion:
1483 eprintf ("%s:%d: ", input_file, lineno)
1484 ==> fprintf (stderr, "%s:%d: ", input_file, lineno)
1486 The variable argument is completely macro-expanded before it is
1487 inserted into the macro expansion, just like an ordinary argument. You
1488 may use the `#' and `##' operators to stringify the variable argument
1489 or to paste its leading or trailing token with another token. (But see
1490 below for an important special case for `##'.)
1492 If your macro is complicated, you may want a more descriptive name
1493 for the variable argument than `__VA_ARGS__'. CPP permits this, as an
1494 extension. You may write an argument name immediately before the
1495 `...'; that name is used for the variable argument. The `eprintf'
1496 macro above could be written
1498 #define eprintf(args...) fprintf (stderr, args)
1500 using this extension. You cannot use `__VA_ARGS__' and this extension
1503 You can have named arguments as well as variable arguments in a
1504 variadic macro. We could define `eprintf' like this, instead:
1506 #define eprintf(format, ...) fprintf (stderr, format, __VA_ARGS__)
1508 This formulation looks more descriptive, but unfortunately it is less
1509 flexible: you must now supply at least one argument after the format
1510 string. In standard C, you cannot omit the comma separating the named
1511 argument from the variable arguments. Furthermore, if you leave the
1512 variable argument empty, you will get a syntax error, because there
1513 will be an extra comma after the format string.
1515 eprintf("success!\n", );
1516 ==> fprintf(stderr, "success!\n", );
1518 GNU CPP has a pair of extensions which deal with this problem.
1519 First, you are allowed to leave the variable argument out entirely:
1521 eprintf ("success!\n")
1522 ==> fprintf(stderr, "success!\n", );
1524 Second, the `##' token paste operator has a special meaning when placed
1525 between a comma and a variable argument. If you write
1527 #define eprintf(format, ...) fprintf (stderr, format, ##__VA_ARGS__)
1529 and the variable argument is left out when the `eprintf' macro is used,
1530 then the comma before the `##' will be deleted. This does _not_ happen
1531 if you pass an empty argument, nor does it happen if the token
1532 preceding `##' is anything other than a comma.
1534 eprintf ("success!\n")
1535 ==> fprintf(stderr, "success!\n");
1537 The above explanation is ambiguous about the case where the only macro
1538 parameter is a variable arguments parameter, as it is meaningless to
1539 try to distinguish whether no argument at all is an empty argument or a
1540 missing argument. In this case the C99 standard is clear that the
1541 comma must remain, however the existing GCC extension used to swallow
1542 the comma. So CPP retains the comma when conforming to a specific C
1543 standard, and drops it otherwise.
1545 C99 mandates that the only place the identifier `__VA_ARGS__' can
1546 appear is in the replacement list of a variadic macro. It may not be
1547 used as a macro name, macro argument name, or within a different type
1548 of macro. It may also be forbidden in open text; the standard is
1549 ambiguous. We recommend you avoid using it except for its defined
1552 Variadic macros are a new feature in C99. GNU CPP has supported them
1553 for a long time, but only with a named variable argument (`args...',
1554 not `...' and `__VA_ARGS__'). If you are concerned with portability to
1555 previous versions of GCC, you should use only named variable arguments.
1556 On the other hand, if you are concerned with portability to other
1557 conforming implementations of C99, you should use only `__VA_ARGS__'.
1559 Previous versions of CPP implemented the comma-deletion extension
1560 much more generally. We have restricted it in this release to minimize
1561 the differences from C99. To get the same effect with both this and
1562 previous versions of GCC, the token preceding the special `##' must be
1563 a comma, and there must be white space between that comma and whatever
1564 comes immediately before it:
1566 #define eprintf(format, args...) fprintf (stderr, format , ##args)
1568 *Note Differences from previous versions::, for the gory details.
1571 File: cpp.info, Node: Predefined Macros, Next: Undefining and Redefining Macros, Prev: Variadic Macros, Up: Macros
1573 3.7 Predefined Macros
1574 =====================
1576 Several object-like macros are predefined; you use them without
1577 supplying their definitions. They fall into three classes: standard,
1578 common, and system-specific.
1580 In C++, there is a fourth category, the named operators. They act
1581 like predefined macros, but you cannot undefine them.
1585 * Standard Predefined Macros::
1586 * Common Predefined Macros::
1587 * System-specific Predefined Macros::
1588 * C++ Named Operators::
1591 File: cpp.info, Node: Standard Predefined Macros, Next: Common Predefined Macros, Up: Predefined Macros
1593 3.7.1 Standard Predefined Macros
1594 --------------------------------
1596 The standard predefined macros are specified by the relevant language
1597 standards, so they are available with all compilers that implement
1598 those standards. Older compilers may not provide all of them. Their
1599 names all start with double underscores.
1602 This macro expands to the name of the current input file, in the
1603 form of a C string constant. This is the path by which the
1604 preprocessor opened the file, not the short name specified in
1605 `#include' or as the input file name argument. For example,
1606 `"/usr/local/include/myheader.h"' is a possible expansion of this
1610 This macro expands to the current input line number, in the form
1611 of a decimal integer constant. While we call it a predefined
1612 macro, it's a pretty strange macro, since its "definition" changes
1613 with each new line of source code.
1615 `__FILE__' and `__LINE__' are useful in generating an error message
1616 to report an inconsistency detected by the program; the message can
1617 state the source line at which the inconsistency was detected. For
1620 fprintf (stderr, "Internal error: "
1621 "negative string length "
1622 "%d at %s, line %d.",
1623 length, __FILE__, __LINE__);
1625 An `#include' directive changes the expansions of `__FILE__' and
1626 `__LINE__' to correspond to the included file. At the end of that
1627 file, when processing resumes on the input file that contained the
1628 `#include' directive, the expansions of `__FILE__' and `__LINE__'
1629 revert to the values they had before the `#include' (but `__LINE__' is
1630 then incremented by one as processing moves to the line after the
1633 A `#line' directive changes `__LINE__', and may change `__FILE__' as
1634 well. *Note Line Control::.
1636 C99 introduces `__func__', and GCC has provided `__FUNCTION__' for a
1637 long time. Both of these are strings containing the name of the
1638 current function (there are slight semantic differences; see the GCC
1639 manual). Neither of them is a macro; the preprocessor does not know the
1640 name of the current function. They tend to be useful in conjunction
1641 with `__FILE__' and `__LINE__', though.
1644 This macro expands to a string constant that describes the date on
1645 which the preprocessor is being run. The string constant contains
1646 eleven characters and looks like `"Feb 12 1996"'. If the day of
1647 the month is less than 10, it is padded with a space on the left.
1649 If GCC cannot determine the current date, it will emit a warning
1650 message (once per compilation) and `__DATE__' will expand to
1654 This macro expands to a string constant that describes the time at
1655 which the preprocessor is being run. The string constant contains
1656 eight characters and looks like `"23:59:01"'.
1658 If GCC cannot determine the current time, it will emit a warning
1659 message (once per compilation) and `__TIME__' will expand to
1663 In normal operation, this macro expands to the constant 1, to
1664 signify that this compiler conforms to ISO Standard C. If GNU CPP
1665 is used with a compiler other than GCC, this is not necessarily
1666 true; however, the preprocessor always conforms to the standard
1667 unless the `-traditional-cpp' option is used.
1669 This macro is not defined if the `-traditional-cpp' option is used.
1671 On some hosts, the system compiler uses a different convention,
1672 where `__STDC__' is normally 0, but is 1 if the user specifies
1673 strict conformance to the C Standard. CPP follows the host
1674 convention when processing system header files, but when
1675 processing user files `__STDC__' is always 1. This has been
1676 reported to cause problems; for instance, some versions of Solaris
1677 provide X Windows headers that expect `__STDC__' to be either
1678 undefined or 1. *Note Invocation::.
1681 This macro expands to the C Standard's version number, a long
1682 integer constant of the form `YYYYMML' where YYYY and MM are the
1683 year and month of the Standard version. This signifies which
1684 version of the C Standard the compiler conforms to. Like
1685 `__STDC__', this is not necessarily accurate for the entire
1686 implementation, unless GNU CPP is being used with GCC.
1688 The value `199409L' signifies the 1989 C standard as amended in
1689 1994, which is the current default; the value `199901L' signifies
1690 the 1999 revision of the C standard. Support for the 1999
1691 revision is not yet complete.
1693 This macro is not defined if the `-traditional-cpp' option is
1694 used, nor when compiling C++ or Objective-C.
1697 This macro is defined, with value 1, if the compiler's target is a
1698 "hosted environment". A hosted environment has the complete
1699 facilities of the standard C library available.
1702 This macro is defined when the C++ compiler is in use. You can use
1703 `__cplusplus' to test whether a header is compiled by a C compiler
1704 or a C++ compiler. This macro is similar to `__STDC_VERSION__', in
1705 that it expands to a version number. A fully conforming
1706 implementation of the 1998 C++ standard will define this macro to
1707 `199711L'. The GNU C++ compiler is not yet fully conforming, so
1708 it uses `1' instead. It is hoped to complete the implementation
1709 of standard C++ in the near future.
1712 This macro is defined, with value 1, when the Objective-C compiler
1713 is in use. You can use `__OBJC__' to test whether a header is
1714 compiled by a C compiler or a Objective-C compiler.
1717 This macro is defined with value 1 when preprocessing assembly
1722 File: cpp.info, Node: Common Predefined Macros, Next: System-specific Predefined Macros, Prev: Standard Predefined Macros, Up: Predefined Macros
1724 3.7.2 Common Predefined Macros
1725 ------------------------------
1727 The common predefined macros are GNU C extensions. They are available
1728 with the same meanings regardless of the machine or operating system on
1729 which you are using GNU C. Their names all start with double
1734 `__GNUC_PATCHLEVEL__'
1735 These macros are defined by all GNU compilers that use the C
1736 preprocessor: C, C++, and Objective-C. Their values are the major
1737 version, minor version, and patch level of the compiler, as integer
1738 constants. For example, GCC 3.2.1 will define `__GNUC__' to 3,
1739 `__GNUC_MINOR__' to 2, and `__GNUC_PATCHLEVEL__' to 1. These
1740 macros are also defined if you invoke the preprocessor directly.
1742 `__GNUC_PATCHLEVEL__' is new to GCC 3.0; it is also present in the
1743 widely-used development snapshots leading up to 3.0 (which identify
1744 themselves as GCC 2.96 or 2.97, depending on which snapshot you
1747 If all you need to know is whether or not your program is being
1748 compiled by GCC, or a non-GCC compiler that claims to accept the
1749 GNU C dialects, you can simply test `__GNUC__'. If you need to
1750 write code which depends on a specific version, you must be more
1751 careful. Each time the minor version is increased, the patch
1752 level is reset to zero; each time the major version is increased
1753 (which happens rarely), the minor version and patch level are
1754 reset. If you wish to use the predefined macros directly in the
1755 conditional, you will need to write it like this:
1757 /* Test for GCC > 3.2.0 */
1758 #if __GNUC__ > 3 || \
1759 (__GNUC__ == 3 && (__GNUC_MINOR__ > 2 || \
1760 (__GNUC_MINOR__ == 2 && \
1761 __GNUC_PATCHLEVEL__ > 0))
1763 Another approach is to use the predefined macros to calculate a
1764 single number, then compare that against a threshold:
1766 #define GCC_VERSION (__GNUC__ * 10000 \
1767 + __GNUC_MINOR__ * 100 \
1768 + __GNUC_PATCHLEVEL__)
1770 /* Test for GCC > 3.2.0 */
1771 #if GCC_VERSION > 30200
1773 Many people find this form easier to understand.
1776 The GNU C++ compiler defines this. Testing it is equivalent to
1777 testing `(__GNUC__ && __cplusplus)'.
1780 GCC defines this macro if and only if the `-ansi' switch, or a
1781 `-std' switch specifying strict conformance to some version of ISO
1782 C, was specified when GCC was invoked. It is defined to `1'.
1783 This macro exists primarily to direct GNU libc's header files to
1784 restrict their definitions to the minimal set found in the 1989 C
1788 This macro expands to the name of the main input file, in the form
1789 of a C string constant. This is the source file that was specified
1790 on the command line of the preprocessor or C compiler.
1793 This macro expands to a decimal integer constant that represents
1794 the depth of nesting in include files. The value of this macro is
1795 incremented on every `#include' directive and decremented at the
1796 end of every included file. It starts out at 0, it's value within
1797 the base file specified on the command line.
1800 This macro is defined if the target uses the ELF object format.
1803 This macro expands to a string constant which describes the
1804 version of the compiler in use. You should not rely on its
1805 contents having any particular form, but it can be counted on to
1806 contain at least the release number.
1811 These macros describe the compilation mode. `__OPTIMIZE__' is
1812 defined in all optimizing compilations. `__OPTIMIZE_SIZE__' is
1813 defined if the compiler is optimizing for size, not speed.
1814 `__NO_INLINE__' is defined if no functions will be inlined into
1815 their callers (when not optimizing, or when inlining has been
1816 specifically disabled by `-fno-inline').
1818 These macros cause certain GNU header files to provide optimized
1819 definitions, using macros or inline functions, of system library
1820 functions. You should not use these macros in any way unless you
1821 make sure that programs will execute with the same effect whether
1822 or not they are defined. If they are defined, their value is 1.
1825 GCC defines this macro if and only if the data type `char' is
1826 unsigned on the target machine. It exists to cause the standard
1827 header file `limits.h' to work correctly. You should not use this
1828 macro yourself; instead, refer to the standard macros defined in
1831 `__WCHAR_UNSIGNED__'
1832 Like `__CHAR_UNSIGNED__', this macro is defined if and only if the
1833 data type `wchar_t' is unsigned and the front-end is in C++ mode.
1835 `__REGISTER_PREFIX__'
1836 This macro expands to a single token (not a string constant) which
1837 is the prefix applied to CPU register names in assembly language
1838 for this target. You can use it to write assembly that is usable
1839 in multiple environments. For example, in the `m68k-aout'
1840 environment it expands to nothing, but in the `m68k-coff'
1841 environment it expands to a single `%'.
1843 `__USER_LABEL_PREFIX__'
1844 This macro expands to a single token which is the prefix applied to
1845 user labels (symbols visible to C code) in assembly. For example,
1846 in the `m68k-aout' environment it expands to an `_', but in the
1847 `m68k-coff' environment it expands to nothing.
1849 This macro will have the correct definition even if
1850 `-f(no-)underscores' is in use, but it will not be correct if
1851 target-specific options that adjust this prefix are used (e.g. the
1852 OSF/rose `-mno-underscores' option).
1860 These macros are defined to the correct underlying types for the
1861 `size_t', `ptrdiff_t', `wchar_t', `wint_t', `intmax_t', and
1862 `uintmax_t' typedefs, respectively. They exist to make the
1863 standard header files `stddef.h' and `wchar.h' work correctly.
1864 You should not use these macros directly; instead, include the
1865 appropriate headers and use the typedefs.
1868 Defined to the number of bits used in the representation of the
1869 `char' data type. It exists to make the standard header given
1870 numerical limits work correctly. You should not use this macro
1871 directly; instead, include the appropriate headers.
1880 Defined to the maximum value of the `signed char', `wchar_t',
1881 `signed short', `signed int', `signed long', `signed long long',
1882 and `intmax_t' types respectively. They exist to make the
1883 standard header given numerical limits work correctly. You should
1884 not use these macros directly; instead, include the appropriate
1887 `__USING_SJLJ_EXCEPTIONS__'
1888 This macro is defined, with value 1, if the compiler uses the old
1889 mechanism based on `setjmp' and `longjmp' for exception handling.
1892 This macro is defined, with value 1, if (and only if) the NeXT
1893 runtime (as in `-fnext-runtime') is in use for Objective-C. If
1894 the GNU runtime is used, this macro is not defined, so that you
1895 can use this macro to determine which runtime (NeXT or GNU) is
1900 These macros are defined, with value 1, if (and only if) the
1901 compilation is for a target where `long int' and pointer both use
1902 64-bits and `int' uses 32-bit.
1905 File: cpp.info, Node: System-specific Predefined Macros, Next: C++ Named Operators, Prev: Common Predefined Macros, Up: Predefined Macros
1907 3.7.3 System-specific Predefined Macros
1908 ---------------------------------------
1910 The C preprocessor normally predefines several macros that indicate what
1911 type of system and machine is in use. They are obviously different on
1912 each target supported by GCC. This manual, being for all systems and
1913 machines, cannot tell you what their names are, but you can use `cpp
1914 -dM' to see them all. *Note Invocation::. All system-specific
1915 predefined macros expand to the constant 1, so you can test them with
1916 either `#ifdef' or `#if'.
1918 The C standard requires that all system-specific macros be part of
1919 the "reserved namespace". All names which begin with two underscores,
1920 or an underscore and a capital letter, are reserved for the compiler and
1921 library to use as they wish. However, historically system-specific
1922 macros have had names with no special prefix; for instance, it is common
1923 to find `unix' defined on Unix systems. For all such macros, GCC
1924 provides a parallel macro with two underscores added at the beginning
1925 and the end. If `unix' is defined, `__unix__' will be defined too.
1926 There will never be more than two underscores; the parallel of `_mips'
1929 When the `-ansi' option, or any `-std' option that requests strict
1930 conformance, is given to the compiler, all the system-specific
1931 predefined macros outside the reserved namespace are suppressed. The
1932 parallel macros, inside the reserved namespace, remain defined.
1934 We are slowly phasing out all predefined macros which are outside the
1935 reserved namespace. You should never use them in new programs, and we
1936 encourage you to correct older code to use the parallel macros whenever
1937 you find it. We don't recommend you use the system-specific macros that
1938 are in the reserved namespace, either. It is better in the long run to
1939 check specifically for features you need, using a tool such as
1943 File: cpp.info, Node: C++ Named Operators, Prev: System-specific Predefined Macros, Up: Predefined Macros
1945 3.7.4 C++ Named Operators
1946 -------------------------
1948 In C++, there are eleven keywords which are simply alternate spellings
1949 of operators normally written with punctuation. These keywords are
1950 treated as such even in the preprocessor. They function as operators in
1951 `#if', and they cannot be defined as macros or poisoned. In C, you can
1952 request that those keywords take their C++ meaning by including
1953 `iso646.h'. That header defines each one as a normal object-like macro
1954 expanding to the appropriate punctuator.
1956 These are the named operators and their corresponding punctuators:
1958 Named Operator Punctuator
1972 File: cpp.info, Node: Undefining and Redefining Macros, Next: Directives Within Macro Arguments, Prev: Predefined Macros, Up: Macros
1974 3.8 Undefining and Redefining Macros
1975 ====================================
1977 If a macro ceases to be useful, it may be "undefined" with the `#undef'
1978 directive. `#undef' takes a single argument, the name of the macro to
1979 undefine. You use the bare macro name, even if the macro is
1980 function-like. It is an error if anything appears on the line after
1981 the macro name. `#undef' has no effect if the name is not a macro.
1986 x = FOO; ==> x = FOO;
1988 Once a macro has been undefined, that identifier may be "redefined"
1989 as a macro by a subsequent `#define' directive. The new definition
1990 need not have any resemblance to the old definition.
1992 However, if an identifier which is currently a macro is redefined,
1993 then the new definition must be "effectively the same" as the old one.
1994 Two macro definitions are effectively the same if:
1995 * Both are the same type of macro (object- or function-like).
1997 * All the tokens of the replacement list are the same.
1999 * If there are any parameters, they are the same.
2001 * Whitespace appears in the same places in both. It need not be
2002 exactly the same amount of whitespace, though. Remember that
2003 comments count as whitespace.
2005 These definitions are effectively the same:
2006 #define FOUR (2 + 2)
2007 #define FOUR (2 + 2)
2008 #define FOUR (2 /* two */ + 2)
2010 #define FOUR (2 + 2)
2011 #define FOUR ( 2+2 )
2012 #define FOUR (2 * 2)
2013 #define FOUR(score,and,seven,years,ago) (2 + 2)
2015 If a macro is redefined with a definition that is not effectively the
2016 same as the old one, the preprocessor issues a warning and changes the
2017 macro to use the new definition. If the new definition is effectively
2018 the same, the redefinition is silently ignored. This allows, for
2019 instance, two different headers to define a common macro. The
2020 preprocessor will only complain if the definitions do not match.
2023 File: cpp.info, Node: Directives Within Macro Arguments, Next: Macro Pitfalls, Prev: Undefining and Redefining Macros, Up: Macros
2025 3.9 Directives Within Macro Arguments
2026 =====================================
2028 Occasionally it is convenient to use preprocessor directives within the
2029 arguments of a macro. The C and C++ standards declare that behavior in
2030 these cases is undefined.
2032 Versions of CPP prior to 3.2 would reject such constructs with an
2033 error message. This was the only syntactic difference between normal
2034 functions and function-like macros, so it seemed attractive to remove
2035 this limitation, and people would often be surprised that they could
2036 not use macros in this way. Moreover, sometimes people would use
2037 conditional compilation in the argument list to a normal library
2038 function like `printf', only to find that after a library upgrade
2039 `printf' had changed to be a function-like macro, and their code would
2040 no longer compile. So from version 3.2 we changed CPP to successfully
2041 process arbitrary directives within macro arguments in exactly the same
2042 way as it would have processed the directive were the function-like
2043 macro invocation not present.
2045 If, within a macro invocation, that macro is redefined, then the new
2046 definition takes effect in time for argument pre-expansion, but the
2047 original definition is still used for argument replacement. Here is a
2048 pathological example:
2060 with the semantics described above.
2063 File: cpp.info, Node: Macro Pitfalls, Prev: Directives Within Macro Arguments, Up: Macros
2068 In this section we describe some special rules that apply to macros and
2069 macro expansion, and point out certain cases in which the rules have
2070 counter-intuitive consequences that you must watch out for.
2075 * Operator Precedence Problems::
2076 * Swallowing the Semicolon::
2077 * Duplication of Side Effects::
2078 * Self-Referential Macros::
2079 * Argument Prescan::
2080 * Newlines in Arguments::
2083 File: cpp.info, Node: Misnesting, Next: Operator Precedence Problems, Up: Macro Pitfalls
2088 When a macro is called with arguments, the arguments are substituted
2089 into the macro body and the result is checked, together with the rest of
2090 the input file, for more macro calls. It is possible to piece together
2091 a macro call coming partially from the macro body and partially from the
2092 arguments. For example,
2094 #define twice(x) (2*(x))
2095 #define call_with_1(x) x(1)
2100 Macro definitions do not have to have balanced parentheses. By
2101 writing an unbalanced open parenthesis in a macro body, it is possible
2102 to create a macro call that begins inside the macro body but ends
2103 outside of it. For example,
2105 #define strange(file) fprintf (file, "%s %d",
2107 strange(stderr) p, 35)
2108 ==> fprintf (stderr, "%s %d", p, 35)
2110 The ability to piece together a macro call can be useful, but the
2111 use of unbalanced open parentheses in a macro body is just confusing,
2112 and should be avoided.
2115 File: cpp.info, Node: Operator Precedence Problems, Next: Swallowing the Semicolon, Prev: Misnesting, Up: Macro Pitfalls
2117 3.10.2 Operator Precedence Problems
2118 -----------------------------------
2120 You may have noticed that in most of the macro definition examples shown
2121 above, each occurrence of a macro argument name had parentheses around
2122 it. In addition, another pair of parentheses usually surround the
2123 entire macro definition. Here is why it is best to write macros that
2126 Suppose you define a macro as follows,
2128 #define ceil_div(x, y) (x + y - 1) / y
2130 whose purpose is to divide, rounding up. (One use for this operation is
2131 to compute how many `int' objects are needed to hold a certain number
2132 of `char' objects.) Then suppose it is used as follows:
2134 a = ceil_div (b & c, sizeof (int));
2135 ==> a = (b & c + sizeof (int) - 1) / sizeof (int);
2137 This does not do what is intended. The operator-precedence rules of C
2138 make it equivalent to this:
2140 a = (b & (c + sizeof (int) - 1)) / sizeof (int);
2142 What we want is this:
2144 a = ((b & c) + sizeof (int) - 1)) / sizeof (int);
2146 Defining the macro as
2148 #define ceil_div(x, y) ((x) + (y) - 1) / (y)
2150 provides the desired result.
2152 Unintended grouping can result in another way. Consider `sizeof
2153 ceil_div(1, 2)'. That has the appearance of a C expression that would
2154 compute the size of the type of `ceil_div (1, 2)', but in fact it means
2155 something very different. Here is what it expands to:
2157 sizeof ((1) + (2) - 1) / (2)
2159 This would take the size of an integer and divide it by two. The
2160 precedence rules have put the division outside the `sizeof' when it was
2161 intended to be inside.
2163 Parentheses around the entire macro definition prevent such problems.
2164 Here, then, is the recommended way to define `ceil_div':
2166 #define ceil_div(x, y) (((x) + (y) - 1) / (y))
2169 File: cpp.info, Node: Swallowing the Semicolon, Next: Duplication of Side Effects, Prev: Operator Precedence Problems, Up: Macro Pitfalls
2171 3.10.3 Swallowing the Semicolon
2172 -------------------------------
2174 Often it is desirable to define a macro that expands into a compound
2175 statement. Consider, for example, the following macro, that advances a
2176 pointer (the argument `p' says where to find it) across whitespace
2179 #define SKIP_SPACES(p, limit) \
2180 { char *lim = (limit); \
2182 if (*p++ != ' ') { \
2185 Here backslash-newline is used to split the macro definition, which must
2186 be a single logical line, so that it resembles the way such code would
2187 be laid out if not part of a macro definition.
2189 A call to this macro might be `SKIP_SPACES (p, lim)'. Strictly
2190 speaking, the call expands to a compound statement, which is a complete
2191 statement with no need for a semicolon to end it. However, since it
2192 looks like a function call, it minimizes confusion if you can use it
2193 like a function call, writing a semicolon afterward, as in `SKIP_SPACES
2196 This can cause trouble before `else' statements, because the
2197 semicolon is actually a null statement. Suppose you write
2200 SKIP_SPACES (p, lim);
2203 The presence of two statements--the compound statement and a null
2204 statement--in between the `if' condition and the `else' makes invalid C
2207 The definition of the macro `SKIP_SPACES' can be altered to solve
2208 this problem, using a `do ... while' statement. Here is how:
2210 #define SKIP_SPACES(p, limit) \
2211 do { char *lim = (limit); \
2213 if (*p++ != ' ') { \
2217 Now `SKIP_SPACES (p, lim);' expands into
2221 which is one statement. The loop executes exactly once; most compilers
2222 generate no extra code for it.
2225 File: cpp.info, Node: Duplication of Side Effects, Next: Self-Referential Macros, Prev: Swallowing the Semicolon, Up: Macro Pitfalls
2227 3.10.4 Duplication of Side Effects
2228 ----------------------------------
2230 Many C programs define a macro `min', for "minimum", like this:
2232 #define min(X, Y) ((X) < (Y) ? (X) : (Y))
2234 When you use this macro with an argument containing a side effect,
2237 next = min (x + y, foo (z));
2239 it expands as follows:
2241 next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
2243 where `x + y' has been substituted for `X' and `foo (z)' for `Y'.
2245 The function `foo' is used only once in the statement as it appears
2246 in the program, but the expression `foo (z)' has been substituted twice
2247 into the macro expansion. As a result, `foo' might be called two times
2248 when the statement is executed. If it has side effects or if it takes
2249 a long time to compute, the results might not be what you intended. We
2250 say that `min' is an "unsafe" macro.
2252 The best solution to this problem is to define `min' in a way that
2253 computes the value of `foo (z)' only once. The C language offers no
2254 standard way to do this, but it can be done with GNU extensions as
2258 ({ typeof (X) x_ = (X); \
2259 typeof (Y) y_ = (Y); \
2260 (x_ < y_) ? x_ : y_; })
2262 The `({ ... })' notation produces a compound statement that acts as
2263 an expression. Its value is the value of its last statement. This
2264 permits us to define local variables and assign each argument to one.
2265 The local variables have underscores after their names to reduce the
2266 risk of conflict with an identifier of wider scope (it is impossible to
2267 avoid this entirely). Now each argument is evaluated exactly once.
2269 If you do not wish to use GNU C extensions, the only solution is to
2270 be careful when _using_ the macro `min'. For example, you can
2271 calculate the value of `foo (z)', save it in a variable, and use that
2274 #define min(X, Y) ((X) < (Y) ? (X) : (Y))
2278 next = min (x + y, tem);
2281 (where we assume that `foo' returns type `int').
2284 File: cpp.info, Node: Self-Referential Macros, Next: Argument Prescan, Prev: Duplication of Side Effects, Up: Macro Pitfalls
2286 3.10.5 Self-Referential Macros
2287 ------------------------------
2289 A "self-referential" macro is one whose name appears in its definition.
2290 Recall that all macro definitions are rescanned for more macros to
2291 replace. If the self-reference were considered a use of the macro, it
2292 would produce an infinitely large expansion. To prevent this, the
2293 self-reference is not considered a macro call. It is passed into the
2294 preprocessor output unchanged. Consider an example:
2296 #define foo (4 + foo)
2298 where `foo' is also a variable in your program.
2300 Following the ordinary rules, each reference to `foo' will expand
2301 into `(4 + foo)'; then this will be rescanned and will expand into `(4
2302 + (4 + foo))'; and so on until the computer runs out of memory.
2304 The self-reference rule cuts this process short after one step, at
2305 `(4 + foo)'. Therefore, this macro definition has the possibly useful
2306 effect of causing the program to add 4 to the value of `foo' wherever
2307 `foo' is referred to.
2309 In most cases, it is a bad idea to take advantage of this feature. A
2310 person reading the program who sees that `foo' is a variable will not
2311 expect that it is a macro as well. The reader will come across the
2312 identifier `foo' in the program and think its value should be that of
2313 the variable `foo', whereas in fact the value is four greater.
2315 One common, useful use of self-reference is to create a macro which
2316 expands to itself. If you write
2320 then the macro `EPERM' expands to `EPERM'. Effectively, it is left
2321 alone by the preprocessor whenever it's used in running text. You can
2322 tell that it's a macro with `#ifdef'. You might do this if you want to
2323 define numeric constants with an `enum', but have `#ifdef' be true for
2326 If a macro `x' expands to use a macro `y', and the expansion of `y'
2327 refers to the macro `x', that is an "indirect self-reference" of `x'.
2328 `x' is not expanded in this case either. Thus, if we have
2333 then `x' and `y' expand as follows:
2341 Each macro is expanded when it appears in the definition of the other
2342 macro, but not when it indirectly appears in its own definition.
2345 File: cpp.info, Node: Argument Prescan, Next: Newlines in Arguments, Prev: Self-Referential Macros, Up: Macro Pitfalls
2347 3.10.6 Argument Prescan
2348 -----------------------
2350 Macro arguments are completely macro-expanded before they are
2351 substituted into a macro body, unless they are stringified or pasted
2352 with other tokens. After substitution, the entire macro body, including
2353 the substituted arguments, is scanned again for macros to be expanded.
2354 The result is that the arguments are scanned _twice_ to expand macro
2357 Most of the time, this has no effect. If the argument contained any
2358 macro calls, they are expanded during the first scan. The result
2359 therefore contains no macro calls, so the second scan does not change
2360 it. If the argument were substituted as given, with no prescan, the
2361 single remaining scan would find the same macro calls and produce the
2364 You might expect the double scan to change the results when a
2365 self-referential macro is used in an argument of another macro (*note
2366 Self-Referential Macros::): the self-referential macro would be
2367 expanded once in the first scan, and a second time in the second scan.
2368 However, this is not what happens. The self-references that do not
2369 expand in the first scan are marked so that they will not expand in the
2372 You might wonder, "Why mention the prescan, if it makes no
2373 difference? And why not skip it and make the preprocessor faster?"
2374 The answer is that the prescan does make a difference in three special
2377 * Nested calls to a macro.
2379 We say that "nested" calls to a macro occur when a macro's argument
2380 contains a call to that very macro. For example, if `f' is a macro
2381 that expects one argument, `f (f (1))' is a nested pair of calls to
2382 `f'. The desired expansion is made by expanding `f (1)' and
2383 substituting that into the definition of `f'. The prescan causes
2384 the expected result to happen. Without the prescan, `f (1)' itself
2385 would be substituted as an argument, and the inner use of `f' would
2386 appear during the main scan as an indirect self-reference and
2387 would not be expanded.
2389 * Macros that call other macros that stringify or concatenate.
2391 If an argument is stringified or concatenated, the prescan does not
2392 occur. If you _want_ to expand a macro, then stringify or
2393 concatenate its expansion, you can do that by causing one macro to
2394 call another macro that does the stringification or concatenation.
2395 For instance, if you have
2397 #define AFTERX(x) X_ ## x
2398 #define XAFTERX(x) AFTERX(x)
2399 #define TABLESIZE 1024
2400 #define BUFSIZE TABLESIZE
2402 then `AFTERX(BUFSIZE)' expands to `X_BUFSIZE', and
2403 `XAFTERX(BUFSIZE)' expands to `X_1024'. (Not to `X_TABLESIZE'.
2404 Prescan always does a complete expansion.)
2406 * Macros used in arguments, whose expansions contain unshielded
2409 This can cause a macro expanded on the second scan to be called
2410 with the wrong number of arguments. Here is an example:
2413 #define bar(x) lose(x)
2414 #define lose(x) (1 + (x))
2416 We would like `bar(foo)' to turn into `(1 + (foo))', which would
2417 then turn into `(1 + (a,b))'. Instead, `bar(foo)' expands into
2418 `lose(a,b)', and you get an error because `lose' requires a single
2419 argument. In this case, the problem is easily solved by the same
2420 parentheses that ought to be used to prevent misnesting of
2421 arithmetic operations:
2425 #define bar(x) lose((x))
2427 The extra pair of parentheses prevents the comma in `foo''s
2428 definition from being interpreted as an argument separator.
2432 File: cpp.info, Node: Newlines in Arguments, Prev: Argument Prescan, Up: Macro Pitfalls
2434 3.10.7 Newlines in Arguments
2435 ----------------------------
2437 The invocation of a function-like macro can extend over many logical
2438 lines. However, in the present implementation, the entire expansion
2439 comes out on one line. Thus line numbers emitted by the compiler or
2440 debugger refer to the line the invocation started on, which might be
2441 different to the line containing the argument causing the problem.
2443 Here is an example illustrating this:
2445 #define ignore_second_arg(a,b,c) a; c
2447 ignore_second_arg (foo (),
2451 The syntax error triggered by the tokens `syntax error' results in an
2452 error message citing line three--the line of ignore_second_arg-- even
2453 though the problematic code comes from line five.
2455 We consider this a bug, and intend to fix it in the near future.
2458 File: cpp.info, Node: Conditionals, Next: Diagnostics, Prev: Macros, Up: Top
2463 A "conditional" is a directive that instructs the preprocessor to
2464 select whether or not to include a chunk of code in the final token
2465 stream passed to the compiler. Preprocessor conditionals can test
2466 arithmetic expressions, or whether a name is defined as a macro, or both
2467 simultaneously using the special `defined' operator.
2469 A conditional in the C preprocessor resembles in some ways an `if'
2470 statement in C, but it is important to understand the difference between
2471 them. The condition in an `if' statement is tested during the
2472 execution of your program. Its purpose is to allow your program to
2473 behave differently from run to run, depending on the data it is
2474 operating on. The condition in a preprocessing conditional directive is
2475 tested when your program is compiled. Its purpose is to allow different
2476 code to be included in the program depending on the situation at the
2477 time of compilation.
2479 However, the distinction is becoming less clear. Modern compilers
2480 often do test `if' statements when a program is compiled, if their
2481 conditions are known not to vary at run time, and eliminate code which
2482 can never be executed. If you can count on your compiler to do this,
2483 you may find that your program is more readable if you use `if'
2484 statements with constant conditions (perhaps determined by macros). Of
2485 course, you can only use this to exclude code, not type definitions or
2486 other preprocessing directives, and you can only do it if the code
2487 remains syntactically valid when it is not to be used.
2489 GCC version 3 eliminates this kind of never-executed code even when
2490 not optimizing. Older versions did it only when optimizing.
2494 * Conditional Uses::
2495 * Conditional Syntax::
2499 File: cpp.info, Node: Conditional Uses, Next: Conditional Syntax, Up: Conditionals
2501 4.1 Conditional Uses
2502 ====================
2504 There are three general reasons to use a conditional.
2506 * A program may need to use different code depending on the machine
2507 or operating system it is to run on. In some cases the code for
2508 one operating system may be erroneous on another operating system;
2509 for example, it might refer to data types or constants that do not
2510 exist on the other system. When this happens, it is not enough to
2511 avoid executing the invalid code. Its mere presence will cause
2512 the compiler to reject the program. With a preprocessing
2513 conditional, the offending code can be effectively excised from
2514 the program when it is not valid.
2516 * You may want to be able to compile the same source file into two
2517 different programs. One version might make frequent time-consuming
2518 consistency checks on its intermediate data, or print the values of
2519 those data for debugging, and the other not.
2521 * A conditional whose condition is always false is one way to
2522 exclude code from the program but keep it as a sort of comment for
2525 Simple programs that do not need system-specific logic or complex
2526 debugging hooks generally will not need to use preprocessing
2530 File: cpp.info, Node: Conditional Syntax, Next: Deleted Code, Prev: Conditional Uses, Up: Conditionals
2532 4.2 Conditional Syntax
2533 ======================
2535 A conditional in the C preprocessor begins with a "conditional
2536 directive": `#if', `#ifdef' or `#ifndef'.
2547 File: cpp.info, Node: Ifdef, Next: If, Up: Conditional Syntax
2552 The simplest sort of conditional is
2560 This block is called a "conditional group". CONTROLLED TEXT will be
2561 included in the output of the preprocessor if and only if MACRO is
2562 defined. We say that the conditional "succeeds" if MACRO is defined,
2563 "fails" if it is not.
2565 The CONTROLLED TEXT inside of a conditional can include
2566 preprocessing directives. They are executed only if the conditional
2567 succeeds. You can nest conditional groups inside other conditional
2568 groups, but they must be completely nested. In other words, `#endif'
2569 always matches the nearest `#ifdef' (or `#ifndef', or `#if'). Also,
2570 you cannot start a conditional group in one file and end it in another.
2572 Even if a conditional fails, the CONTROLLED TEXT inside it is still
2573 run through initial transformations and tokenization. Therefore, it
2574 must all be lexically valid C. Normally the only way this matters is
2575 that all comments and string literals inside a failing conditional group
2576 must still be properly ended.
2578 The comment following the `#endif' is not required, but it is a good
2579 practice if there is a lot of CONTROLLED TEXT, because it helps people
2580 match the `#endif' to the corresponding `#ifdef'. Older programs
2581 sometimes put MACRO directly after the `#endif' without enclosing it in
2582 a comment. This is invalid code according to the C standard. CPP
2583 accepts it with a warning. It never affects which `#ifndef' the
2586 Sometimes you wish to use some code if a macro is _not_ defined.
2587 You can do this by writing `#ifndef' instead of `#ifdef'. One common
2588 use of `#ifndef' is to include code only the first time a header file
2589 is included. *Note Once-Only Headers::.
2591 Macro definitions can vary between compilations for several reasons.
2592 Here are some samples.
2594 * Some macros are predefined on each kind of machine (*note
2595 System-specific Predefined Macros::). This allows you to provide
2596 code specially tuned for a particular machine.
2598 * System header files define more macros, associated with the
2599 features they implement. You can test these macros with
2600 conditionals to avoid using a system feature on a machine where it
2603 * Macros can be defined or undefined with the `-D' and `-U' command
2604 line options when you compile the program. You can arrange to
2605 compile the same source file into two different programs by
2606 choosing a macro name to specify which program you want, writing
2607 conditionals to test whether or how this macro is defined, and
2608 then controlling the state of the macro with command line options,
2609 perhaps set in the Makefile. *Note Invocation::.
2611 * Your program might have a special header file (often called
2612 `config.h') that is adjusted when the program is compiled. It can
2613 define or not define macros depending on the features of the
2614 system and the desired capabilities of the program. The
2615 adjustment can be automated by a tool such as `autoconf', or done
2619 File: cpp.info, Node: If, Next: Defined, Prev: Ifdef, Up: Conditional Syntax
2624 The `#if' directive allows you to test the value of an arithmetic
2625 expression, rather than the mere existence of one macro. Its syntax is
2631 #endif /* EXPRESSION */
2633 EXPRESSION is a C expression of integer type, subject to stringent
2634 restrictions. It may contain
2636 * Integer constants.
2638 * Character constants, which are interpreted as they would be in
2641 * Arithmetic operators for addition, subtraction, multiplication,
2642 division, bitwise operations, shifts, comparisons, and logical
2643 operations (`&&' and `||'). The latter two obey the usual
2644 short-circuiting rules of standard C.
2646 * Macros. All macros in the expression are expanded before actual
2647 computation of the expression's value begins.
2649 * Uses of the `defined' operator, which lets you check whether macros
2650 are defined in the middle of an `#if'.
2652 * Identifiers that are not macros, which are all considered to be the
2653 number zero. This allows you to write `#if MACRO' instead of
2654 `#ifdef MACRO', if you know that MACRO, when defined, will always
2655 have a nonzero value. Function-like macros used without their
2656 function call parentheses are also treated as zero.
2658 In some contexts this shortcut is undesirable. The `-Wundef'
2659 option causes GCC to warn whenever it encounters an identifier
2660 which is not a macro in an `#if'.
2662 The preprocessor does not know anything about types in the language.
2663 Therefore, `sizeof' operators are not recognized in `#if', and neither
2664 are `enum' constants. They will be taken as identifiers which are not
2665 macros, and replaced by zero. In the case of `sizeof', this is likely
2666 to cause the expression to be invalid.
2668 The preprocessor calculates the value of EXPRESSION. It carries out
2669 all calculations in the widest integer type known to the compiler; on
2670 most machines supported by GCC this is 64 bits. This is not the same
2671 rule as the compiler uses to calculate the value of a constant
2672 expression, and may give different results in some cases. If the value
2673 comes out to be nonzero, the `#if' succeeds and the CONTROLLED TEXT is
2674 included; otherwise it is skipped.
2677 File: cpp.info, Node: Defined, Next: Else, Prev: If, Up: Conditional Syntax
2682 The special operator `defined' is used in `#if' and `#elif' expressions
2683 to test whether a certain name is defined as a macro. `defined NAME'
2684 and `defined (NAME)' are both expressions whose value is 1 if NAME is
2685 defined as a macro at the current point in the program, and 0
2686 otherwise. Thus, `#if defined MACRO' is precisely equivalent to
2689 `defined' is useful when you wish to test more than one macro for
2690 existence at once. For example,
2692 #if defined (__vax__) || defined (__ns16000__)
2694 would succeed if either of the names `__vax__' or `__ns16000__' is
2697 Conditionals written like this:
2699 #if defined BUFSIZE && BUFSIZE >= 1024
2701 can generally be simplified to just `#if BUFSIZE >= 1024', since if
2702 `BUFSIZE' is not defined, it will be interpreted as having the value
2705 If the `defined' operator appears as a result of a macro expansion,
2706 the C standard says the behavior is undefined. GNU cpp treats it as a
2707 genuine `defined' operator and evaluates it normally. It will warn
2708 wherever your code uses this feature if you use the command-line option
2709 `-pedantic', since other compilers may handle it differently.
2712 File: cpp.info, Node: Else, Next: Elif, Prev: Defined, Up: Conditional Syntax
2717 The `#else' directive can be added to a conditional to provide
2718 alternative text to be used if the condition fails. This is what it
2723 #else /* Not EXPRESSION */
2725 #endif /* Not EXPRESSION */
2727 If EXPRESSION is nonzero, the TEXT-IF-TRUE is included and the
2728 TEXT-IF-FALSE is skipped. If EXPRESSION is zero, the opposite happens.
2730 You can use `#else' with `#ifdef' and `#ifndef', too.
2733 File: cpp.info, Node: Elif, Prev: Else, Up: Conditional Syntax
2738 One common case of nested conditionals is used to check for more than
2739 two possible alternatives. For example, you might have
2751 Another conditional directive, `#elif', allows this to be
2752 abbreviated as follows:
2758 #else /* X != 2 and X != 1*/
2760 #endif /* X != 2 and X != 1*/
2762 `#elif' stands for "else if". Like `#else', it goes in the middle
2763 of a conditional group and subdivides it; it does not require a
2764 matching `#endif' of its own. Like `#if', the `#elif' directive
2765 includes an expression to be tested. The text following the `#elif' is
2766 processed only if the original `#if'-condition failed and the `#elif'
2769 More than one `#elif' can go in the same conditional group. Then
2770 the text after each `#elif' is processed only if the `#elif' condition
2771 succeeds after the original `#if' and all previous `#elif' directives
2772 within it have failed.
2774 `#else' is allowed after any number of `#elif' directives, but
2775 `#elif' may not follow `#else'.
2778 File: cpp.info, Node: Deleted Code, Prev: Conditional Syntax, Up: Conditionals
2783 If you replace or delete a part of the program but want to keep the old
2784 code around for future reference, you often cannot simply comment it
2785 out. Block comments do not nest, so the first comment inside the old
2786 code will end the commenting-out. The probable result is a flood of
2789 One way to avoid this problem is to use an always-false conditional
2790 instead. For instance, put `#if 0' before the deleted code and
2791 `#endif' after it. This works even if the code being turned off
2792 contains conditionals, but they must be entire conditionals (balanced
2793 `#if' and `#endif').
2795 Some people use `#ifdef notdef' instead. This is risky, because
2796 `notdef' might be accidentally defined as a macro, and then the
2797 conditional would succeed. `#if 0' can be counted on to fail.
2799 Do not use `#if 0' for comments which are not C code. Use a real
2800 comment, instead. The interior of `#if 0' must consist of complete
2801 tokens; in particular, single-quote characters must balance. Comments
2802 often contain unbalanced single-quote characters (known in English as
2803 apostrophes). These confuse `#if 0'. They don't confuse `/*'.
2806 File: cpp.info, Node: Diagnostics, Next: Line Control, Prev: Conditionals, Up: Top
2811 The directive `#error' causes the preprocessor to report a fatal error.
2812 The tokens forming the rest of the line following `#error' are used as
2815 You would use `#error' inside of a conditional that detects a
2816 combination of parameters which you know the program does not properly
2817 support. For example, if you know that the program will not run
2818 properly on a VAX, you might write
2821 #error "Won't work on VAXen. See comments at get_last_object."
2824 If you have several configuration parameters that must be set up by
2825 the installation in a consistent way, you can use conditionals to detect
2826 an inconsistency and report it with `#error'. For example,
2828 #if !defined(UNALIGNED_INT_ASM_OP) && defined(DWARF2_DEBUGGING_INFO)
2829 #error "DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP."
2832 The directive `#warning' is like `#error', but causes the
2833 preprocessor to issue a warning and continue preprocessing. The tokens
2834 following `#warning' are used as the warning message.
2836 You might use `#warning' in obsolete header files, with a message
2837 directing the user to the header file which should be used instead.
2839 Neither `#error' nor `#warning' macro-expands its argument.
2840 Internal whitespace sequences are each replaced with a single space.
2841 The line must consist of complete tokens. It is wisest to make the
2842 argument of these directives be a single string constant; this avoids
2843 problems with apostrophes and the like.
2846 File: cpp.info, Node: Line Control, Next: Pragmas, Prev: Diagnostics, Up: Top
2851 The C preprocessor informs the C compiler of the location in your source
2852 code where each token came from. Presently, this is just the file name
2853 and line number. All the tokens resulting from macro expansion are
2854 reported as having appeared on the line of the source file where the
2855 outermost macro was used. We intend to be more accurate in the future.
2857 If you write a program which generates source code, such as the
2858 `bison' parser generator, you may want to adjust the preprocessor's
2859 notion of the current file name and line number by hand. Parts of the
2860 output from `bison' are generated from scratch, other parts come from a
2861 standard parser file. The rest are copied verbatim from `bison''s
2862 input. You would like compiler error messages and symbolic debuggers
2863 to be able to refer to `bison''s input file.
2865 `bison' or any such program can arrange this by writing `#line'
2866 directives into the output file. `#line' is a directive that specifies
2867 the original line number and source file name for subsequent input in
2868 the current preprocessor input file. `#line' has three variants:
2871 LINENUM is a non-negative decimal integer constant. It specifies
2872 the line number which should be reported for the following line of
2873 input. Subsequent lines are counted from LINENUM.
2875 `#line LINENUM FILENAME'
2876 LINENUM is the same as for the first form, and has the same
2877 effect. In addition, FILENAME is a string constant. The
2878 following line and all subsequent lines are reported to come from
2879 the file it specifies, until something else happens to change that.
2880 FILENAME is interpreted according to the normal rules for a string
2881 constant: backslash escapes are interpreted. This is different
2884 Previous versions of CPP did not interpret escapes in `#line'; we
2885 have changed it because the standard requires they be interpreted,
2886 and most other compilers do.
2888 `#line ANYTHING ELSE'
2889 ANYTHING ELSE is checked for macro calls, which are expanded. The
2890 result should match one of the above two forms.
2892 `#line' directives alter the results of the `__FILE__' and
2893 `__LINE__' predefined macros from that point on. *Note Standard
2894 Predefined Macros::. They do not have any effect on `#include''s idea
2895 of the directory containing the current file. This is a change from
2896 GCC 2.95. Previously, a file reading
2898 #line 1 "../src/gram.y"
2901 would search for `gram.h' in `../src', then the `-I' chain; the
2902 directory containing the physical source file would not be searched.
2903 In GCC 3.0 and later, the `#include' is not affected by the presence of
2904 a `#line' referring to a different directory.
2906 We made this change because the old behavior caused problems when
2907 generated source files were transported between machines. For instance,
2908 it is common practice to ship generated parsers with a source release,
2909 so that people building the distribution do not need to have yacc or
2910 Bison installed. These files frequently have `#line' directives
2911 referring to the directory tree of the system where the distribution was
2912 created. If GCC tries to search for headers in those directories, the
2913 build is likely to fail.
2915 The new behavior can cause failures too, if the generated file is not
2916 in the same directory as its source and it attempts to include a header
2917 which would be visible searching from the directory containing the
2918 source file. However, this problem is easily solved with an additional
2919 `-I' switch on the command line. The failures caused by the old
2920 semantics could sometimes be corrected only by editing the generated
2921 files, which is difficult and error-prone.
2924 File: cpp.info, Node: Pragmas, Next: Other Directives, Prev: Line Control, Up: Top
2929 The `#pragma' directive is the method specified by the C standard for
2930 providing additional information to the compiler, beyond what is
2931 conveyed in the language itself. Three forms of this directive
2932 (commonly known as "pragmas") are specified by the 1999 C standard. A
2933 C compiler is free to attach any meaning it likes to other pragmas.
2935 GCC has historically preferred to use extensions to the syntax of the
2936 language, such as `__attribute__', for this purpose. However, GCC does
2937 define a few pragmas of its own. These mostly have effects on the
2938 entire translation unit or source file.
2940 In GCC version 3, all GNU-defined, supported pragmas have been given
2941 a `GCC' prefix. This is in line with the `STDC' prefix on all pragmas
2942 defined by C99. For backward compatibility, pragmas which were
2943 recognized by previous versions are still recognized without the `GCC'
2944 prefix, but that usage is deprecated. Some older pragmas are
2945 deprecated in their entirety. They are not recognized with the `GCC'
2946 prefix. *Note Obsolete Features::.
2948 C99 introduces the `_Pragma' operator. This feature addresses a
2949 major problem with `#pragma': being a directive, it cannot be produced
2950 as the result of macro expansion. `_Pragma' is an operator, much like
2951 `sizeof' or `defined', and can be embedded in a macro.
2953 Its syntax is `_Pragma (STRING-LITERAL)', where STRING-LITERAL can
2954 be either a normal or wide-character string literal. It is
2955 destringized, by replacing all `\\' with a single `\' and all `\"' with
2956 a `"'. The result is then processed as if it had appeared as the right
2957 hand side of a `#pragma' directive. For example,
2959 _Pragma ("GCC dependency \"parse.y\"")
2961 has the same effect as `#pragma GCC dependency "parse.y"'. The same
2962 effect could be achieved using macros, for example
2964 #define DO_PRAGMA(x) _Pragma (#x)
2965 DO_PRAGMA (GCC dependency "parse.y")
2967 The standard is unclear on where a `_Pragma' operator can appear.
2968 The preprocessor does not accept it within a preprocessing conditional
2969 directive like `#if'. To be safe, you are probably best keeping it out
2970 of directives other than `#define', and putting it on a line of its own.
2972 This manual documents the pragmas which are meaningful to the
2973 preprocessor itself. Other pragmas are meaningful to the C or C++
2974 compilers. They are documented in the GCC manual.
2976 `#pragma GCC dependency'
2977 `#pragma GCC dependency' allows you to check the relative dates of
2978 the current file and another file. If the other file is more
2979 recent than the current file, a warning is issued. This is useful
2980 if the current file is derived from the other file, and should be
2981 regenerated. The other file is searched for using the normal
2982 include search path. Optional trailing text can be used to give
2983 more information in the warning message.
2985 #pragma GCC dependency "parse.y"
2986 #pragma GCC dependency "/usr/include/time.h" rerun fixincludes
2988 `#pragma GCC poison'
2989 Sometimes, there is an identifier that you want to remove
2990 completely from your program, and make sure that it never creeps
2991 back in. To enforce this, you can "poison" the identifier with
2992 this pragma. `#pragma GCC poison' is followed by a list of
2993 identifiers to poison. If any of those identifiers appears
2994 anywhere in the source after the directive, it is a hard error.
2997 #pragma GCC poison printf sprintf fprintf
2998 sprintf(some_string, "hello");
3000 will produce an error.
3002 If a poisoned identifier appears as part of the expansion of a
3003 macro which was defined before the identifier was poisoned, it
3004 will _not_ cause an error. This lets you poison an identifier
3005 without worrying about system headers defining macros that use it.
3009 #define strrchr rindex
3010 #pragma GCC poison rindex
3011 strrchr(some_string, 'h');
3013 will not produce an error.
3015 `#pragma GCC system_header'
3016 This pragma takes no arguments. It causes the rest of the code in
3017 the current file to be treated as if it came from a system header.
3018 *Note System Headers::.
3022 File: cpp.info, Node: Other Directives, Next: Preprocessor Output, Prev: Pragmas, Up: Top
3027 The `#ident' directive takes one argument, a string constant. On some
3028 systems, that string constant is copied into a special segment of the
3029 object file. On other systems, the directive is ignored.
3031 This directive is not part of the C standard, but it is not an
3032 official GNU extension either. We believe it came from System V.
3034 The `#sccs' directive is recognized, because it appears in the
3035 header files of some systems. It is a very old, obscure, extension
3036 which we did not invent, and we have been unable to find any
3037 documentation of what it should do, so GCC simply ignores it.
3039 The "null directive" consists of a `#' followed by a newline, with
3040 only whitespace (including comments) in between. A null directive is
3041 understood as a preprocessing directive but has no effect on the
3042 preprocessor output. The primary significance of the existence of the
3043 null directive is that an input line consisting of just a `#' will
3044 produce no output, rather than a line of output containing just a `#'.
3045 Supposedly some old C programs contain such lines.
3048 File: cpp.info, Node: Preprocessor Output, Next: Traditional Mode, Prev: Other Directives, Up: Top
3050 9 Preprocessor Output
3051 *********************
3053 When the C preprocessor is used with the C, C++, or Objective-C
3054 compilers, it is integrated into the compiler and communicates a stream
3055 of binary tokens directly to the compiler's parser. However, it can
3056 also be used in the more conventional standalone mode, where it produces
3059 The output from the C preprocessor looks much like the input, except
3060 that all preprocessing directive lines have been replaced with blank
3061 lines and all comments with spaces. Long runs of blank lines are
3064 The ISO standard specifies that it is implementation defined whether
3065 a preprocessor preserves whitespace between tokens, or replaces it with
3066 e.g. a single space. In GNU CPP, whitespace between tokens is collapsed
3067 to become a single space, with the exception that the first token on a
3068 non-directive line is preceded with sufficient spaces that it appears in
3069 the same column in the preprocessed output that it appeared in the
3070 original source file. This is so the output is easy to read. *Note
3071 Differences from previous versions::. CPP does not insert any
3072 whitespace where there was none in the original source, except where
3073 necessary to prevent an accidental token paste.
3075 Source file name and line number information is conveyed by lines of
3078 # LINENUM FILENAME FLAGS
3080 These are called "linemarkers". They are inserted as needed into the
3081 output (but never within a string or character constant). They mean
3082 that the following line originated in file FILENAME at line LINENUM.
3083 FILENAME will never contain any non-printing characters; they are
3084 replaced with octal escape sequences.
3086 After the file name comes zero or more flags, which are `1', `2',
3087 `3', or `4'. If there are multiple flags, spaces separate them. Here
3088 is what the flags mean:
3091 This indicates the start of a new file.
3094 This indicates returning to a file (after having included another
3098 This indicates that the following text comes from a system header
3099 file, so certain warnings should be suppressed.
3102 This indicates that the following text should be treated as being
3103 wrapped in an implicit `extern "C"' block.
3105 As an extension, the preprocessor accepts linemarkers in
3106 non-assembler input files. They are treated like the corresponding
3107 `#line' directive, (*note Line Control::), except that trailing flags
3108 are permitted, and are interpreted with the meanings described above.
3109 If multiple flags are given, they must be in ascending order.
3111 Some directives may be duplicated in the output of the preprocessor.
3112 These are `#ident' (always), `#pragma' (only if the preprocessor does
3113 not handle the pragma itself), and `#define' and `#undef' (with certain
3114 debugging options). If this happens, the `#' of the directive will
3115 always be in the first column, and there will be no space between the
3116 `#' and the directive name. If macro expansion happens to generate
3117 tokens which might be mistaken for a duplicated directive, a space will
3118 be inserted between the `#' and the directive name.
3121 File: cpp.info, Node: Traditional Mode, Next: Implementation Details, Prev: Preprocessor Output, Up: Top
3126 Traditional (pre-standard) C preprocessing is rather different from the
3127 preprocessing specified by the standard. When GCC is given the
3128 `-traditional-cpp' option, it attempts to emulate a traditional
3131 GCC versions 3.2 and later only support traditional mode semantics in
3132 the preprocessor, and not in the compiler front ends. This chapter
3133 outlines the traditional preprocessor semantics we implemented.
3135 The implementation does not correspond precisely to the behavior of
3136 earlier versions of GCC, nor to any true traditional preprocessor.
3137 After all, inconsistencies among traditional implementations were a
3138 major motivation for C standardization. However, we intend that it
3139 should be compatible with true traditional preprocessors in all ways
3140 that actually matter.
3144 * Traditional lexical analysis::
3145 * Traditional macros::
3146 * Traditional miscellany::
3147 * Traditional warnings::
3150 File: cpp.info, Node: Traditional lexical analysis, Next: Traditional macros, Up: Traditional Mode
3152 10.1 Traditional lexical analysis
3153 =================================
3155 The traditional preprocessor does not decompose its input into tokens
3156 the same way a standards-conforming preprocessor does. The input is
3157 simply treated as a stream of text with minimal internal form.
3159 This implementation does not treat trigraphs (*note trigraphs::)
3160 specially since they were an invention of the standards committee. It
3161 handles arbitrarily-positioned escaped newlines properly and splices
3162 the lines as you would expect; many traditional preprocessors did not
3165 The form of horizontal whitespace in the input file is preserved in
3166 the output. In particular, hard tabs remain hard tabs. This can be
3167 useful if, for example, you are preprocessing a Makefile.
3169 Traditional CPP only recognizes C-style block comments, and treats
3170 the `/*' sequence as introducing a comment only if it lies outside
3171 quoted text. Quoted text is introduced by the usual single and double
3172 quotes, and also by an initial `<' in a `#include' directive.
3174 Traditionally, comments are completely removed and are not replaced
3175 with a space. Since a traditional compiler does its own tokenization
3176 of the output of the preprocessor, this means that comments can
3177 effectively be used as token paste operators. However, comments behave
3178 like separators for text handled by the preprocessor itself, since it
3179 doesn't re-lex its input. For example, in
3183 `foo' and `bar' are distinct identifiers and expanded separately if
3184 they happen to be macros. In other words, this directive is equivalent
3193 Generally speaking, in traditional mode an opening quote need not
3194 have a matching closing quote. In particular, a macro may be defined
3195 with replacement text that contains an unmatched quote. Of course, if
3196 you attempt to compile preprocessed output containing an unmatched quote
3197 you will get a syntax error.
3199 However, all preprocessing directives other than `#define' require
3200 matching quotes. For example:
3202 #define m This macro's fine and has an unmatched quote
3203 "/* This is not a comment. */
3204 /* This is a comment. The following #include directive
3208 Just as for the ISO preprocessor, what would be a closing quote can
3209 be escaped with a backslash to prevent the quoted text from closing.
3212 File: cpp.info, Node: Traditional macros, Next: Traditional miscellany, Prev: Traditional lexical analysis, Up: Traditional Mode
3214 10.2 Traditional macros
3215 =======================
3217 The major difference between traditional and ISO macros is that the
3218 former expand to text rather than to a token sequence. CPP removes all
3219 leading and trailing horizontal whitespace from a macro's replacement
3220 text before storing it, but preserves the form of internal whitespace.
3222 One consequence is that it is legitimate for the replacement text to
3223 contain an unmatched quote (*note Traditional lexical analysis::). An
3224 unclosed string or character constant continues into the text following
3225 the macro call. Similarly, the text at the end of a macro's expansion
3226 can run together with the text after the macro invocation to produce a
3229 Normally comments are removed from the replacement text after the
3230 macro is expanded, but if the `-CC' option is passed on the command
3231 line comments are preserved. (In fact, the current implementation
3232 removes comments even before saving the macro replacement text, but it
3233 careful to do it in such a way that the observed effect is identical
3234 even in the function-like macro case.)
3236 The ISO stringification operator `#' and token paste operator `##'
3237 have no special meaning. As explained later, an effect similar to
3238 these operators can be obtained in a different way. Macro names that
3239 are embedded in quotes, either from the main file or after macro
3240 replacement, do not expand.
3242 CPP replaces an unquoted object-like macro name with its replacement
3243 text, and then rescans it for further macros to replace. Unlike
3244 standard macro expansion, traditional macro expansion has no provision
3245 to prevent recursion. If an object-like macro appears unquoted in its
3246 replacement text, it will be replaced again during the rescan pass, and
3247 so on _ad infinitum_. GCC detects when it is expanding recursive
3248 macros, emits an error message, and continues after the offending macro
3252 #define INC(x) PLUS+x
3256 Function-like macros are similar in form but quite different in
3257 behavior to their ISO counterparts. Their arguments are contained
3258 within parentheses, are comma-separated, and can cross physical lines.
3259 Commas within nested parentheses are not treated as argument
3260 separators. Similarly, a quote in an argument cannot be left unclosed;
3261 a following comma or parenthesis that comes before the closing quote is
3262 treated like any other character. There is no facility for handling
3265 This implementation removes all comments from macro arguments, unless
3266 the `-C' option is given. The form of all other horizontal whitespace
3267 in arguments is preserved, including leading and trailing whitespace.
3272 is treated as an invocation of the macro `f' with a single argument
3273 consisting of a single space. If you want to invoke a function-like
3274 macro that takes no arguments, you must not leave any whitespace
3275 between the parentheses.
3277 If a macro argument crosses a new line, the new line is replaced with
3278 a space when forming the argument. If the previous line contained an
3279 unterminated quote, the following line inherits the quoted state.
3281 Traditional preprocessors replace parameters in the replacement text
3282 with their arguments regardless of whether the parameters are within
3283 quotes or not. This provides a way to stringize arguments. For example
3286 str(/* A comment */some text )
3289 Note that the comment is removed, but that the trailing space is
3290 preserved. Here is an example of using a comment to effect token
3293 #define suffix(x) foo_/**/x
3298 File: cpp.info, Node: Traditional miscellany, Next: Traditional warnings, Prev: Traditional macros, Up: Traditional Mode
3300 10.3 Traditional miscellany
3301 ===========================
3303 Here are some things to be aware of when using the traditional
3306 * Preprocessing directives are recognized only when their leading
3307 `#' appears in the first column. There can be no whitespace
3308 between the beginning of the line and the `#', but whitespace can
3311 * A true traditional C preprocessor does not recognize `#error' or
3312 `#pragma', and may not recognize `#elif'. CPP supports all the
3313 directives in traditional mode that it supports in ISO mode,
3314 including extensions, with the exception that the effects of
3315 `#pragma GCC poison' are undefined.
3317 * __STDC__ is not defined.
3319 * If you use digraphs the behavior is undefined.
3321 * If a line that looks like a directive appears within macro
3322 arguments, the behavior is undefined.
3326 File: cpp.info, Node: Traditional warnings, Prev: Traditional miscellany, Up: Traditional Mode
3328 10.4 Traditional warnings
3329 =========================
3331 You can request warnings about features that did not exist, or worked
3332 differently, in traditional C with the `-Wtraditional' option. GCC
3333 does not warn about features of ISO C which you must use when you are
3334 using a conforming compiler, such as the `#' and `##' operators.
3336 Presently `-Wtraditional' warns about:
3338 * Macro parameters that appear within string literals in the macro
3339 body. In traditional C macro replacement takes place within
3340 string literals, but does not in ISO C.
3342 * In traditional C, some preprocessor directives did not exist.
3343 Traditional preprocessors would only consider a line to be a
3344 directive if the `#' appeared in column 1 on the line. Therefore
3345 `-Wtraditional' warns about directives that traditional C
3346 understands but would ignore because the `#' does not appear as the
3347 first character on the line. It also suggests you hide directives
3348 like `#pragma' not understood by traditional C by indenting them.
3349 Some traditional implementations would not recognize `#elif', so it
3350 suggests avoiding it altogether.
3352 * A function-like macro that appears without an argument list. In
3353 some traditional preprocessors this was an error. In ISO C it
3354 merely means that the macro is not expanded.
3356 * The unary plus operator. This did not exist in traditional C.
3358 * The `U' and `LL' integer constant suffixes, which were not
3359 available in traditional C. (Traditional C does support the `L'
3360 suffix for simple long integer constants.) You are not warned
3361 about uses of these suffixes in macros defined in system headers.
3362 For instance, `UINT_MAX' may well be defined as `4294967295U', but
3363 you will not be warned if you use `UINT_MAX'.
3365 You can usually avoid the warning, and the related warning about
3366 constants which are so large that they are unsigned, by writing the
3367 integer constant in question in hexadecimal, with no U suffix.
3368 Take care, though, because this gives the wrong result in exotic
3372 File: cpp.info, Node: Implementation Details, Next: Invocation, Prev: Traditional Mode, Up: Top
3374 11 Implementation Details
3375 *************************
3377 Here we document details of how the preprocessor's implementation
3378 affects its user-visible behavior. You should try to avoid undue
3379 reliance on behavior described here, as it is possible that it will
3380 change subtly in future implementations.
3382 Also documented here are obsolete features and changes from previous
3387 * Implementation-defined behavior::
3388 * Implementation limits::
3389 * Obsolete Features::
3390 * Differences from previous versions::
3393 File: cpp.info, Node: Implementation-defined behavior, Next: Implementation limits, Up: Implementation Details
3395 11.1 Implementation-defined behavior
3396 ====================================
3398 This is how CPP behaves in all the cases which the C standard describes
3399 as "implementation-defined". This term means that the implementation
3400 is free to do what it likes, but must document its choice and stick to
3403 * The mapping of physical source file multi-byte characters to the
3404 execution character set.
3406 Currently, CPP requires its input to be ASCII or UTF-8. The
3407 execution character set may be controlled by the user, with the
3408 `-ftarget-charset' and `-ftarget-wide-charset' options.
3410 * Identifier characters.
3412 The C and C++ standards allow identifiers to be composed of `_'
3413 and the alphanumeric characters. C++ and C99 also allow universal
3414 character names (not implemented in GCC), and C99 further permits
3415 implementation-defined characters.
3417 GCC allows the `$' character in identifiers as an extension for
3418 most targets. This is true regardless of the `std=' switch, since
3419 this extension cannot conflict with standards-conforming programs.
3420 When preprocessing assembler, however, dollars are not identifier
3421 characters by default.
3423 Currently the targets that by default do not permit `$' are AVR,
3424 IP2K, MMIX, MIPS Irix 3, ARM aout, and PowerPC targets for the AIX
3425 and BeOS operating systems.
3427 You can override the default with `-fdollars-in-identifiers' or
3428 `fno-dollars-in-identifiers'. *Note fdollars-in-identifiers::.
3430 * Non-empty sequences of whitespace characters.
3432 In textual output, each whitespace sequence is collapsed to a
3433 single space. For aesthetic reasons, the first token on each
3434 non-directive line of output is preceded with sufficient spaces
3435 that it appears in the same column as it did in the original
3438 * The numeric value of character constants in preprocessor
3441 The preprocessor and compiler interpret character constants in the
3442 same way; i.e. escape sequences such as `\a' are given the values
3443 they would have on the target machine.
3445 The compiler values a multi-character character constant a
3446 character at a time, shifting the previous value left by the
3447 number of bits per target character, and then or-ing in the
3448 bit-pattern of the new character truncated to the width of a
3449 target character. The final bit-pattern is given type `int', and
3450 is therefore signed, regardless of whether single characters are
3451 signed or not (a slight change from versions 3.1 and earlier of
3452 GCC). If there are more characters in the constant than would fit
3453 in the target `int' the compiler issues a warning, and the excess
3454 leading characters are ignored.
3456 For example, `'ab'' for a target with an 8-bit `char' would be
3458 `(int) ((unsigned char) 'a' * 256 + (unsigned char) 'b')', and
3460 `(int) ((unsigned char) '\234' * 256 + (unsigned char) 'a')'.
3462 * Source file inclusion.
3464 For a discussion on how the preprocessor locates header files,
3465 *Note Include Operation::.
3467 * Interpretation of the filename resulting from a macro-expanded
3468 `#include' directive.
3470 *Note Computed Includes::.
3472 * Treatment of a `#pragma' directive that after macro-expansion
3473 results in a standard pragma.
3475 No macro expansion occurs on any `#pragma' directive line, so the
3476 question does not arise.
3478 Note that GCC does not yet implement any of the standard pragmas.
3482 File: cpp.info, Node: Implementation limits, Next: Obsolete Features, Prev: Implementation-defined behavior, Up: Implementation Details
3484 11.2 Implementation limits
3485 ==========================
3487 CPP has a small number of internal limits. This section lists the
3488 limits which the C standard requires to be no lower than some minimum,
3489 and all the others known. It is intended that there should be as few
3490 limits as possible. If you encounter an undocumented or inconvenient
3491 limit, please report that as a bug. *Note Reporting Bugs: (gcc)Bugs.
3493 Where we say something is limited "only by available memory", that
3494 means that internal data structures impose no intrinsic limit, and space
3495 is allocated with `malloc' or equivalent. The actual limit will
3496 therefore depend on many things, such as the size of other things
3497 allocated by the compiler at the same time, the amount of memory
3498 consumed by other processes on the same computer, etc.
3500 * Nesting levels of `#include' files.
3502 We impose an arbitrary limit of 200 levels, to avoid runaway
3503 recursion. The standard requires at least 15 levels.
3505 * Nesting levels of conditional inclusion.
3507 The C standard mandates this be at least 63. CPP is limited only
3508 by available memory.
3510 * Levels of parenthesized expressions within a full expression.
3512 The C standard requires this to be at least 63. In preprocessor
3513 conditional expressions, it is limited only by available memory.
3515 * Significant initial characters in an identifier or macro name.
3517 The preprocessor treats all characters as significant. The C
3518 standard requires only that the first 63 be significant.
3520 * Number of macros simultaneously defined in a single translation
3523 The standard requires at least 4095 be possible. CPP is limited
3524 only by available memory.
3526 * Number of parameters in a macro definition and arguments in a
3529 We allow `USHRT_MAX', which is no smaller than 65,535. The minimum
3530 required by the standard is 127.
3532 * Number of characters on a logical source line.
3534 The C standard requires a minimum of 4096 be permitted. CPP places
3535 no limits on this, but you may get incorrect column numbers
3536 reported in diagnostics for lines longer than 65,535 characters.
3538 * Maximum size of a source file.
3540 The standard does not specify any lower limit on the maximum size
3541 of a source file. GNU cpp maps files into memory, so it is
3542 limited by the available address space. This is generally at
3543 least two gigabytes. Depending on the operating system, the size
3544 of physical memory may or may not be a limitation.
3548 File: cpp.info, Node: Obsolete Features, Next: Differences from previous versions, Prev: Implementation limits, Up: Implementation Details
3550 11.3 Obsolete Features
3551 ======================
3553 CPP has a number of features which are present mainly for compatibility
3554 with older programs. We discourage their use in new code. In some
3555 cases, we plan to remove the feature in a future version of GCC.
3560 * Obsolete once-only headers::
3563 File: cpp.info, Node: Assertions, Next: Obsolete once-only headers, Up: Obsolete Features
3568 "Assertions" are a deprecated alternative to macros in writing
3569 conditionals to test what sort of computer or system the compiled
3570 program will run on. Assertions are usually predefined, but you can
3571 define them with preprocessing directives or command-line options.
3573 Assertions were intended to provide a more systematic way to describe
3574 the compiler's target system. However, in practice they are just as
3575 unpredictable as the system-specific predefined macros. In addition,
3576 they are not part of any standard, and only a few compilers support
3577 them. Therefore, the use of assertions is *less* portable than the use
3578 of system-specific predefined macros. We recommend you do not use them
3581 An assertion looks like this:
3585 PREDICATE must be a single identifier. ANSWER can be any sequence of
3586 tokens; all characters are significant except for leading and trailing
3587 whitespace, and differences in internal whitespace sequences are
3588 ignored. (This is similar to the rules governing macro redefinition.)
3589 Thus, `(x + y)' is different from `(x+y)' but equivalent to
3590 `( x + y )'. Parentheses do not nest inside an answer.
3592 To test an assertion, you write it in an `#if'. For example, this
3593 conditional succeeds if either `vax' or `ns16000' has been asserted as
3594 an answer for `machine'.
3596 #if #machine (vax) || #machine (ns16000)
3598 You can test whether _any_ answer is asserted for a predicate by
3599 omitting the answer in the conditional:
3603 Assertions are made with the `#assert' directive. Its sole argument
3604 is the assertion to make, without the leading `#' that identifies
3605 assertions in conditionals.
3607 #assert PREDICATE (ANSWER)
3609 You may make several assertions with the same predicate and different
3610 answers. Subsequent assertions do not override previous ones for the
3611 same predicate. All the answers for any given predicate are
3612 simultaneously true.
3614 Assertions can be canceled with the `#unassert' directive. It has
3615 the same syntax as `#assert'. In that form it cancels only the answer
3616 which was specified on the `#unassert' line; other answers for that
3617 predicate remain true. You can cancel an entire predicate by leaving
3622 In either form, if no such assertion has been made, `#unassert' has no
3625 You can also make or cancel assertions using command line options.
3629 File: cpp.info, Node: Obsolete once-only headers, Prev: Assertions, Up: Obsolete Features
3631 11.3.2 Obsolete once-only headers
3632 ---------------------------------
3634 CPP supports two more ways of indicating that a header file should be
3635 read only once. Neither one is as portable as a wrapper `#ifndef', and
3636 we recommend you do not use them in new programs.
3638 In the Objective-C language, there is a variant of `#include' called
3639 `#import' which includes a file, but does so at most once. If you use
3640 `#import' instead of `#include', then you don't need the conditionals
3641 inside the header file to prevent multiple inclusion of the contents.
3642 GCC permits the use of `#import' in C and C++ as well as Objective-C.
3643 However, it is not in standard C or C++ and should therefore not be
3644 used by portable programs.
3646 `#import' is not a well designed feature. It requires the users of
3647 a header file to know that it should only be included once. It is much
3648 better for the header file's implementor to write the file so that users
3649 don't need to know this. Using a wrapper `#ifndef' accomplishes this
3652 In the present implementation, a single use of `#import' will
3653 prevent the file from ever being read again, by either `#import' or
3654 `#include'. You should not rely on this; do not use both `#import' and
3655 `#include' to refer to the same header file.
3657 Another way to prevent a header file from being included more than
3658 once is with the `#pragma once' directive. If `#pragma once' is seen
3659 when scanning a header file, that file will never be read again, no
3662 `#pragma once' does not have the problems that `#import' does, but
3663 it is not recognized by all preprocessors, so you cannot rely on it in
3667 File: cpp.info, Node: Differences from previous versions, Prev: Obsolete Features, Up: Implementation Details
3669 11.4 Differences from previous versions
3670 =======================================
3672 This section details behavior which has changed from previous versions
3673 of CPP. We do not plan to change it again in the near future, but we
3674 do not promise not to, either.
3676 The "previous versions" discussed here are 2.95 and before. The
3677 behavior of GCC 3.0 is mostly the same as the behavior of the widely
3678 used 2.96 and 2.97 development snapshots. Where there are differences,
3679 they generally represent bugs in the snapshots.
3683 This option has been deprecated in 4.0. `-iquote' is meant to
3684 replace the need for this option.
3686 * Order of evaluation of `#' and `##' operators
3688 The standard does not specify the order of evaluation of a chain of
3689 `##' operators, nor whether `#' is evaluated before, after, or at
3690 the same time as `##'. You should therefore not write any code
3691 which depends on any specific ordering. It is possible to
3692 guarantee an ordering, if you need one, by suitable use of nested
3695 An example of where this might matter is pasting the arguments `1',
3696 `e' and `-2'. This would be fine for left-to-right pasting, but
3697 right-to-left pasting would produce an invalid token `e-2'.
3699 GCC 3.0 evaluates `#' and `##' at the same time and strictly left
3700 to right. Older versions evaluated all `#' operators first, then
3701 all `##' operators, in an unreliable order.
3703 * The form of whitespace between tokens in preprocessor output
3705 *Note Preprocessor Output::, for the current textual format. This
3706 is also the format used by stringification. Normally, the
3707 preprocessor communicates tokens directly to the compiler's
3708 parser, and whitespace does not come up at all.
3710 Older versions of GCC preserved all whitespace provided by the
3711 user and inserted lots more whitespace of their own, because they
3712 could not accurately predict when extra spaces were needed to
3713 prevent accidental token pasting.
3715 * Optional argument when invoking rest argument macros
3717 As an extension, GCC permits you to omit the variable arguments
3718 entirely when you use a variable argument macro. This is
3719 forbidden by the 1999 C standard, and will provoke a pedantic
3720 warning with GCC 3.0. Previous versions accepted it silently.
3722 * `##' swallowing preceding text in rest argument macros
3724 Formerly, in a macro expansion, if `##' appeared before a variable
3725 arguments parameter, and the set of tokens specified for that
3726 argument in the macro invocation was empty, previous versions of
3727 CPP would back up and remove the preceding sequence of
3728 non-whitespace characters (*not* the preceding token). This
3729 extension is in direct conflict with the 1999 C standard and has
3730 been drastically pared back.
3732 In the current version of the preprocessor, if `##' appears between
3733 a comma and a variable arguments parameter, and the variable
3734 argument is omitted entirely, the comma will be removed from the
3735 expansion. If the variable argument is empty, or the token before
3736 `##' is not a comma, then `##' behaves as a normal token paste.
3738 * `#line' and `#include'
3740 The `#line' directive used to change GCC's notion of the
3741 "directory containing the current file", used by `#include' with a
3742 double-quoted header file name. In 3.0 and later, it does not.
3743 *Note Line Control::, for further explanation.
3747 In GCC 2.95 and previous, the string constant argument to `#line'
3748 was treated the same way as the argument to `#include': backslash
3749 escapes were not honored, and the string ended at the second `"'.
3750 This is not compliant with the C standard. In GCC 3.0, an attempt
3751 was made to correct the behavior, so that the string was treated
3752 as a real string constant, but it turned out to be buggy. In 3.1,
3753 the bugs have been fixed. (We are not fixing the bugs in 3.0
3754 because they affect relatively few people and the fix is quite
3759 File: cpp.info, Node: Invocation, Next: Environment Variables, Prev: Implementation Details, Up: Top
3764 Most often when you use the C preprocessor you will not have to invoke
3765 it explicitly: the C compiler will do so automatically. However, the
3766 preprocessor is sometimes useful on its own. All the options listed
3767 here are also acceptable to the C compiler and have the same meaning,
3768 except that the C compiler has different rules for specifying the output
3771 _Note:_ Whether you use the preprocessor by way of `gcc' or `cpp',
3772 the "compiler driver" is run first. This program's purpose is to
3773 translate your command into invocations of the programs that do the
3774 actual work. Their command line interfaces are similar but not
3775 identical to the documented interface, and may change without notice.
3777 The C preprocessor expects two file names as arguments, INFILE and
3778 OUTFILE. The preprocessor reads INFILE together with any other files
3779 it specifies with `#include'. All the output generated by the combined
3780 input files is written in OUTFILE.
3782 Either INFILE or OUTFILE may be `-', which as INFILE means to read
3783 from standard input and as OUTFILE means to write to standard output.
3784 Also, if either file is omitted, it means the same as if `-' had been
3785 specified for that file.
3787 Unless otherwise noted, or the option ends in `=', all options which
3788 take an argument may have that argument appear either immediately after
3789 the option, or with a space between option and argument: `-Ifoo' and
3790 `-I foo' have the same effect.
3792 Many options have multi-letter names; therefore multiple
3793 single-letter options may _not_ be grouped: `-dM' is very different from
3797 Predefine NAME as a macro, with definition `1'.
3799 `-D NAME=DEFINITION'
3800 The contents of DEFINITION are tokenized and processed as if they
3801 appeared during translation phase three in a `#define' directive.
3802 In particular, the definition will be truncated by embedded
3805 If you are invoking the preprocessor from a shell or shell-like
3806 program you may need to use the shell's quoting syntax to protect
3807 characters such as spaces that have a meaning in the shell syntax.
3809 If you wish to define a function-like macro on the command line,
3810 write its argument list with surrounding parentheses before the
3811 equals sign (if any). Parentheses are meaningful to most shells,
3812 so you will need to quote the option. With `sh' and `csh',
3813 `-D'NAME(ARGS...)=DEFINITION'' works.
3815 `-D' and `-U' options are processed in the order they are given on
3816 the command line. All `-imacros FILE' and `-include FILE' options
3817 are processed after all `-D' and `-U' options.
3820 Cancel any previous definition of NAME, either built in or
3821 provided with a `-D' option.
3824 Do not predefine any system-specific or GCC-specific macros. The
3825 standard predefined macros remain defined. *Note Standard
3826 Predefined Macros::.
3829 Add the directory DIR to the list of directories to be searched
3830 for header files. *Note Search Path::. Directories named by `-I'
3831 are searched before the standard system include directories. If
3832 the directory DIR is a standard system include directory, the
3833 option is ignored to ensure that the default search order for
3834 system directories and the special treatment of system headers are
3835 not defeated (*note System Headers::) .
3838 Write output to FILE. This is the same as specifying FILE as the
3839 second non-option argument to `cpp'. `gcc' has a different
3840 interpretation of a second non-option argument, so you must use
3841 `-o' to specify the output file.
3844 Turns on all optional warnings which are desirable for normal code.
3845 At present this is `-Wcomment', `-Wtrigraphs', `-Wmultichar' and a
3846 warning about integer promotion causing a change of sign in `#if'
3847 expressions. Note that many of the preprocessor's warnings are on
3848 by default and have no options to control them.
3852 Warn whenever a comment-start sequence `/*' appears in a `/*'
3853 comment, or whenever a backslash-newline appears in a `//' comment.
3854 (Both forms have the same effect.)
3857 Most trigraphs in comments cannot affect the meaning of the
3858 program. However, a trigraph that would form an escaped newline
3859 (`??/' at the end of a line) can, by changing where the comment
3860 begins or ends. Therefore, only trigraphs that would form escaped
3861 newlines produce warnings inside a comment.
3863 This option is implied by `-Wall'. If `-Wall' is not given, this
3864 option is still enabled unless trigraphs are enabled. To get
3865 trigraph conversion without warnings, but get the other `-Wall'
3866 warnings, use `-trigraphs -Wall -Wno-trigraphs'.
3869 Warn about certain constructs that behave differently in
3870 traditional and ISO C. Also warn about ISO C constructs that have
3871 no traditional C equivalent, and problematic constructs which
3872 should be avoided. *Note Traditional Mode::.
3875 Warn the first time `#import' is used.
3878 Warn whenever an identifier which is not a macro is encountered in
3879 an `#if' directive, outside of `defined'. Such identifiers are
3883 Warn about macros defined in the main file that are unused. A
3884 macro is "used" if it is expanded or tested for existence at least
3885 once. The preprocessor will also warn if the macro has not been
3886 used at the time it is redefined or undefined.
3888 Built-in macros, macros defined on the command line, and macros
3889 defined in include files are not warned about.
3891 _Note:_ If a macro is actually used, but only used in skipped
3892 conditional blocks, then CPP will report it as unused. To avoid
3893 the warning in such a case, you might improve the scope of the
3894 macro's definition by, for example, moving it into the first
3895 skipped block. Alternatively, you could provide a dummy use with
3898 #if defined the_macro_causing_the_warning
3902 Warn whenever an `#else' or an `#endif' are followed by text.
3903 This usually happens in code of the form
3911 The second and third `FOO' should be in comments, but often are not
3912 in older programs. This warning is on by default.
3915 Make all warnings into hard errors. Source code which triggers
3916 warnings will be rejected.
3919 Issue warnings for code in system headers. These are normally
3920 unhelpful in finding bugs in your own code, therefore suppressed.
3921 If you are responsible for the system library, you may want to see
3925 Suppress all warnings, including those which GNU CPP issues by
3929 Issue all the mandatory diagnostics listed in the C standard.
3930 Some of them are left out by default, since they trigger
3931 frequently on harmless code.
3934 Issue all the mandatory diagnostics, and make all mandatory
3935 diagnostics into errors. This includes mandatory diagnostics that
3936 GCC issues without `-pedantic' but treats as warnings.
3939 Instead of outputting the result of preprocessing, output a rule
3940 suitable for `make' describing the dependencies of the main source
3941 file. The preprocessor outputs one `make' rule containing the
3942 object file name for that source file, a colon, and the names of
3943 all the included files, including those coming from `-include' or
3944 `-imacros' command line options.
3946 Unless specified explicitly (with `-MT' or `-MQ'), the object file
3947 name consists of the basename of the source file with any suffix
3948 replaced with object file suffix. If there are many included
3949 files then the rule is split into several lines using `\'-newline.
3950 The rule has no commands.
3952 This option does not suppress the preprocessor's debug output,
3953 such as `-dM'. To avoid mixing such debug output with the
3954 dependency rules you should explicitly specify the dependency
3955 output file with `-MF', or use an environment variable like
3956 `DEPENDENCIES_OUTPUT' (*note Environment Variables::). Debug
3957 output will still be sent to the regular output stream as normal.
3959 Passing `-M' to the driver implies `-E', and suppresses warnings
3960 with an implicit `-w'.
3963 Like `-M' but do not mention header files that are found in system
3964 header directories, nor header files that are included, directly
3965 or indirectly, from such a header.
3967 This implies that the choice of angle brackets or double quotes in
3968 an `#include' directive does not in itself determine whether that
3969 header will appear in `-MM' dependency output. This is a slight
3970 change in semantics from GCC versions 3.0 and earlier.
3973 When used with `-M' or `-MM', specifies a file to write the
3974 dependencies to. If no `-MF' switch is given the preprocessor
3975 sends the rules to the same place it would have sent preprocessed
3978 When used with the driver options `-MD' or `-MMD', `-MF' overrides
3979 the default dependency output file.
3982 In conjunction with an option such as `-M' requesting dependency
3983 generation, `-MG' assumes missing header files are generated files
3984 and adds them to the dependency list without raising an error.
3985 The dependency filename is taken directly from the `#include'
3986 directive without prepending any path. `-MG' also suppresses
3987 preprocessed output, as a missing header file renders this useless.
3989 This feature is used in automatic updating of makefiles.
3992 This option instructs CPP to add a phony target for each dependency
3993 other than the main file, causing each to depend on nothing. These
3994 dummy rules work around errors `make' gives if you remove header
3995 files without updating the `Makefile' to match.
3997 This is typical output:
3999 test.o: test.c test.h
4004 Change the target of the rule emitted by dependency generation. By
4005 default CPP takes the name of the main input file, including any
4006 path, deletes any file suffix such as `.c', and appends the
4007 platform's usual object suffix. The result is the target.
4009 An `-MT' option will set the target to be exactly the string you
4010 specify. If you want multiple targets, you can specify them as a
4011 single argument to `-MT', or use multiple `-MT' options.
4013 For example, `-MT '$(objpfx)foo.o'' might give
4015 $(objpfx)foo.o: foo.c
4018 Same as `-MT', but it quotes any characters which are special to
4019 Make. `-MQ '$(objpfx)foo.o'' gives
4021 $$(objpfx)foo.o: foo.c
4023 The default target is automatically quoted, as if it were given
4027 `-MD' is equivalent to `-M -MF FILE', except that `-E' is not
4028 implied. The driver determines FILE based on whether an `-o'
4029 option is given. If it is, the driver uses its argument but with
4030 a suffix of `.d', otherwise it take the basename of the input file
4031 and applies a `.d' suffix.
4033 If `-MD' is used in conjunction with `-E', any `-o' switch is
4034 understood to specify the dependency output file (but *note -MF:
4035 dashMF.), but if used without `-E', each `-o' is understood to
4036 specify a target object file.
4038 Since `-E' is not implied, `-MD' can be used to generate a
4039 dependency output file as a side-effect of the compilation process.
4042 Like `-MD' except mention only user header files, not system
4048 `-x assembler-with-cpp'
4049 Specify the source language: C, C++, Objective-C, or assembly.
4050 This has nothing to do with standards conformance or extensions;
4051 it merely selects which base syntax to expect. If you give none
4052 of these options, cpp will deduce the language from the extension
4053 of the source file: `.c', `.cc', `.m', or `.S'. Some other common
4054 extensions for C++ and assembly are also recognized. If cpp does
4055 not recognize the extension, it will treat the file as C; this is
4056 the most generic mode.
4058 _Note:_ Previous versions of cpp accepted a `-lang' option which
4059 selected both the language and the standards conformance level.
4060 This option has been removed, because it conflicts with the `-l'
4065 Specify the standard to which the code should conform. Currently
4066 CPP knows about C and C++ standards; others may be added in the
4069 STANDARD may be one of:
4072 The ISO C standard from 1990. `c89' is the customary
4073 shorthand for this version of the standard.
4075 The `-ansi' option is equivalent to `-std=c89'.
4078 The 1990 C standard, as amended in 1994.
4084 The revised ISO C standard, published in December 1999.
4085 Before publication, this was known as C9X.
4088 The 1990 C standard plus GNU extensions. This is the default.
4092 The 1999 C standard plus GNU extensions.
4095 The 1998 ISO C++ standard plus amendments.
4098 The same as `-std=c++98' plus GNU extensions. This is the
4099 default for C++ code.
4102 Split the include path. Any directories specified with `-I'
4103 options before `-I-' are searched only for headers requested with
4104 `#include "FILE"'; they are not searched for `#include <FILE>'.
4105 If additional directories are specified with `-I' options after
4106 the `-I-', those directories are searched for all `#include'
4109 In addition, `-I-' inhibits the use of the directory of the current
4110 file directory as the first search directory for `#include "FILE"'.
4111 *Note Search Path::. This option has been deprecated.
4114 Do not search the standard system directories for header files.
4115 Only the directories you have specified with `-I' options (and the
4116 directory of the current file, if appropriate) are searched.
4119 Do not search for header files in the C++-specific standard
4120 directories, but do still search the other standard directories.
4121 (This option is used when building the C++ library.)
4124 Process FILE as if `#include "file"' appeared as the first line of
4125 the primary source file. However, the first directory searched
4126 for FILE is the preprocessor's working directory _instead of_ the
4127 directory containing the main source file. If not found there, it
4128 is searched for in the remainder of the `#include "..."' search
4131 If multiple `-include' options are given, the files are included
4132 in the order they appear on the command line.
4135 Exactly like `-include', except that any output produced by
4136 scanning FILE is thrown away. Macros it defines remain defined.
4137 This allows you to acquire all the macros from a header without
4138 also processing its declarations.
4140 All files specified by `-imacros' are processed before all files
4141 specified by `-include'.
4144 Search DIR for header files, but do it _after_ all directories
4145 specified with `-I' and the standard system directories have been
4146 exhausted. DIR is treated as a system include directory.
4149 Specify PREFIX as the prefix for subsequent `-iwithprefix'
4150 options. If the prefix represents a directory, you should include
4154 `-iwithprefixbefore DIR'
4155 Append DIR to the prefix specified previously with `-iprefix', and
4156 add the resulting directory to the include search path.
4157 `-iwithprefixbefore' puts it in the same place `-I' would;
4158 `-iwithprefix' puts it where `-idirafter' would.
4161 Search DIR for header files, after all directories specified by
4162 `-I' but before the standard system directories. Mark it as a
4163 system directory, so that it gets the same special treatment as is
4164 applied to the standard system directories. *Note System
4168 Search DIR only for header files requested with `#include "FILE"';
4169 they are not searched for `#include <FILE>', before all
4170 directories specified by `-I' and before the standard system
4171 directories. *Note Search Path::.
4173 `-fdollars-in-identifiers'
4174 Accept `$' in identifiers. *Note Identifier characters::.
4177 Indicate to the preprocessor that the input file has already been
4178 preprocessed. This suppresses things like macro expansion,
4179 trigraph conversion, escaped newline splicing, and processing of
4180 most directives. The preprocessor still recognizes and removes
4181 comments, so that you can pass a file preprocessed with `-C' to
4182 the compiler without problems. In this mode the integrated
4183 preprocessor is little more than a tokenizer for the front ends.
4185 `-fpreprocessed' is implicit if the input file has one of the
4186 extensions `.i', `.ii' or `.mi'. These are the extensions that
4187 GCC uses for preprocessed files created by `-save-temps'.
4190 Set the distance between tab stops. This helps the preprocessor
4191 report correct column numbers in warnings or errors, even if tabs
4192 appear on the line. If the value is less than 1 or greater than
4193 100, the option is ignored. The default is 8.
4195 `-fexec-charset=CHARSET'
4196 Set the execution character set, used for string and character
4197 constants. The default is UTF-8. CHARSET can be any encoding
4198 supported by the system's `iconv' library routine.
4200 `-fwide-exec-charset=CHARSET'
4201 Set the wide execution character set, used for wide string and
4202 character constants. The default is UTF-32 or UTF-16, whichever
4203 corresponds to the width of `wchar_t'. As with `-fexec-charset',
4204 CHARSET can be any encoding supported by the system's `iconv'
4205 library routine; however, you will have problems with encodings
4206 that do not fit exactly in `wchar_t'.
4208 `-finput-charset=CHARSET'
4209 Set the input character set, used for translation from the
4210 character set of the input file to the source character set used
4211 by GCC. If the locale does not specify, or GCC cannot get this
4212 information from the locale, the default is UTF-8. This can be
4213 overridden by either the locale or this command line option.
4214 Currently the command line option takes precedence if there's a
4215 conflict. CHARSET can be any encoding supported by the system's
4216 `iconv' library routine.
4218 `-fworking-directory'
4219 Enable generation of linemarkers in the preprocessor output that
4220 will let the compiler know the current working directory at the
4221 time of preprocessing. When this option is enabled, the
4222 preprocessor will emit, after the initial linemarker, a second
4223 linemarker with the current working directory followed by two
4224 slashes. GCC will use this directory, when it's present in the
4225 preprocessed input, as the directory emitted as the current
4226 working directory in some debugging information formats. This
4227 option is implicitly enabled if debugging information is enabled,
4228 but this can be inhibited with the negated form
4229 `-fno-working-directory'. If the `-P' flag is present in the
4230 command line, this option has no effect, since no `#line'
4231 directives are emitted whatsoever.
4234 Do not print column numbers in diagnostics. This may be necessary
4235 if diagnostics are being scanned by a program that does not
4236 understand the column numbers, such as `dejagnu'.
4238 `-A PREDICATE=ANSWER'
4239 Make an assertion with the predicate PREDICATE and answer ANSWER.
4240 This form is preferred to the older form `-A PREDICATE(ANSWER)',
4241 which is still supported, because it does not use shell special
4242 characters. *Note Assertions::.
4244 `-A -PREDICATE=ANSWER'
4245 Cancel an assertion with the predicate PREDICATE and answer ANSWER.
4248 CHARS is a sequence of one or more of the following characters,
4249 and must not be preceded by a space. Other characters are
4250 interpreted by the compiler proper, or reserved for future
4251 versions of GCC, and so are silently ignored. If you specify
4252 characters whose behavior conflicts, the result is undefined.
4255 Instead of the normal output, generate a list of `#define'
4256 directives for all the macros defined during the execution of
4257 the preprocessor, including predefined macros. This gives
4258 you a way of finding out what is predefined in your version
4259 of the preprocessor. Assuming you have no file `foo.h', the
4262 touch foo.h; cpp -dM foo.h
4264 will show all the predefined macros.
4267 Like `M' except in two respects: it does _not_ include the
4268 predefined macros, and it outputs _both_ the `#define'
4269 directives and the result of preprocessing. Both kinds of
4270 output go to the standard output file.
4273 Like `D', but emit only the macro names, not their expansions.
4276 Output `#include' directives in addition to the result of
4280 Inhibit generation of linemarkers in the output from the
4281 preprocessor. This might be useful when running the preprocessor
4282 on something that is not C code, and will be sent to a program
4283 which might be confused by the linemarkers. *Note Preprocessor
4287 Do not discard comments. All comments are passed through to the
4288 output file, except for comments in processed directives, which
4289 are deleted along with the directive.
4291 You should be prepared for side effects when using `-C'; it causes
4292 the preprocessor to treat comments as tokens in their own right.
4293 For example, comments appearing at the start of what would be a
4294 directive line have the effect of turning that line into an
4295 ordinary source line, since the first token on the line is no
4299 Do not discard comments, including during macro expansion. This is
4300 like `-C', except that comments contained within macros are also
4301 passed through to the output file where the macro is expanded.
4303 In addition to the side-effects of the `-C' option, the `-CC'
4304 option causes all C++-style comments inside a macro to be
4305 converted to C-style comments. This is to prevent later use of
4306 that macro from inadvertently commenting out the remainder of the
4309 The `-CC' option is generally used to support lint comments.
4312 Try to imitate the behavior of old-fashioned C preprocessors, as
4313 opposed to ISO C preprocessors. *Note Traditional Mode::.
4316 Process trigraph sequences. *Note Initial processing::.
4319 Enable special code to work around file systems which only permit
4320 very short file names, such as MS-DOS.
4324 Print text describing all the command line options instead of
4325 preprocessing anything.
4328 Verbose mode. Print out GNU CPP's version number at the beginning
4329 of execution, and report the final form of the include path.
4332 Print the name of each header file used, in addition to other
4333 normal activities. Each name is indented to show how deep in the
4334 `#include' stack it is. Precompiled header files are also
4335 printed, even if they are found to be invalid; an invalid
4336 precompiled header file is printed with `...x' and a valid one
4341 Print out GNU CPP's version number. With one dash, proceed to
4342 preprocess as normal. With two dashes, exit immediately.
4345 File: cpp.info, Node: Environment Variables, Next: GNU Free Documentation License, Prev: Invocation, Up: Top
4347 13 Environment Variables
4348 ************************
4350 This section describes the environment variables that affect how CPP
4351 operates. You can use them to specify directories or prefixes to use
4352 when searching for include files, or to control dependency output.
4354 Note that you can also specify places to search using options such as
4355 `-I', and control dependency output with options like `-M' (*note
4356 Invocation::). These take precedence over environment variables, which
4357 in turn take precedence over the configuration of GCC.
4361 `CPLUS_INCLUDE_PATH'
4363 Each variable's value is a list of directories separated by a
4364 special character, much like `PATH', in which to look for header
4365 files. The special character, `PATH_SEPARATOR', is
4366 target-dependent and determined at GCC build time. For Microsoft
4367 Windows-based targets it is a semicolon, and for almost all other
4368 targets it is a colon.
4370 `CPATH' specifies a list of directories to be searched as if
4371 specified with `-I', but after any paths given with `-I' options
4372 on the command line. This environment variable is used regardless
4373 of which language is being preprocessed.
4375 The remaining environment variables apply only when preprocessing
4376 the particular language indicated. Each specifies a list of
4377 directories to be searched as if specified with `-isystem', but
4378 after any paths given with `-isystem' options on the command line.
4380 In all these variables, an empty element instructs the compiler to
4381 search its current working directory. Empty elements can appear
4382 at the beginning or end of a path. For instance, if the value of
4383 `CPATH' is `:/special/include', that has the same effect as
4384 `-I. -I/special/include'.
4386 See also *Note Search Path::.
4388 `DEPENDENCIES_OUTPUT'
4389 If this variable is set, its value specifies how to output
4390 dependencies for Make based on the non-system header files
4391 processed by the compiler. System header files are ignored in the
4394 The value of `DEPENDENCIES_OUTPUT' can be just a file name, in
4395 which case the Make rules are written to that file, guessing the
4396 target name from the source file name. Or the value can have the
4397 form `FILE TARGET', in which case the rules are written to file
4398 FILE using TARGET as the target name.
4400 In other words, this environment variable is equivalent to
4401 combining the options `-MM' and `-MF' (*note Invocation::), with
4402 an optional `-MT' switch too.
4404 `SUNPRO_DEPENDENCIES'
4405 This variable is the same as `DEPENDENCIES_OUTPUT' (see above),
4406 except that system header files are not ignored, so it implies
4407 `-M' rather than `-MM'. However, the dependence on the main input
4408 file is omitted. *Note Invocation::.
4411 File: cpp.info, Node: GNU Free Documentation License, Next: Index of Directives, Prev: Environment Variables, Up: Top
4413 GNU Free Documentation License
4414 ******************************
4416 Version 1.2, November 2002
4418 Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
4419 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
4421 Everyone is permitted to copy and distribute verbatim copies
4422 of this license document, but changing it is not allowed.
4426 The purpose of this License is to make a manual, textbook, or other
4427 functional and useful document "free" in the sense of freedom: to
4428 assure everyone the effective freedom to copy and redistribute it,
4429 with or without modifying it, either commercially or
4430 noncommercially. Secondarily, this License preserves for the
4431 author and publisher a way to get credit for their work, while not
4432 being considered responsible for modifications made by others.
4434 This License is a kind of "copyleft", which means that derivative
4435 works of the document must themselves be free in the same sense.
4436 It complements the GNU General Public License, which is a copyleft
4437 license designed for free software.
4439 We have designed this License in order to use it for manuals for
4440 free software, because free software needs free documentation: a
4441 free program should come with manuals providing the same freedoms
4442 that the software does. But this License is not limited to
4443 software manuals; it can be used for any textual work, regardless
4444 of subject matter or whether it is published as a printed book.
4445 We recommend this License principally for works whose purpose is
4446 instruction or reference.
4448 1. APPLICABILITY AND DEFINITIONS
4450 This License applies to any manual or other work, in any medium,
4451 that contains a notice placed by the copyright holder saying it
4452 can be distributed under the terms of this License. Such a notice
4453 grants a world-wide, royalty-free license, unlimited in duration,
4454 to use that work under the conditions stated herein. The
4455 "Document", below, refers to any such manual or work. Any member
4456 of the public is a licensee, and is addressed as "you". You
4457 accept the license if you copy, modify or distribute the work in a
4458 way requiring permission under copyright law.
4460 A "Modified Version" of the Document means any work containing the
4461 Document or a portion of it, either copied verbatim, or with
4462 modifications and/or translated into another language.
4464 A "Secondary Section" is a named appendix or a front-matter section
4465 of the Document that deals exclusively with the relationship of the
4466 publishers or authors of the Document to the Document's overall
4467 subject (or to related matters) and contains nothing that could
4468 fall directly within that overall subject. (Thus, if the Document
4469 is in part a textbook of mathematics, a Secondary Section may not
4470 explain any mathematics.) The relationship could be a matter of
4471 historical connection with the subject or with related matters, or
4472 of legal, commercial, philosophical, ethical or political position
4475 The "Invariant Sections" are certain Secondary Sections whose
4476 titles are designated, as being those of Invariant Sections, in
4477 the notice that says that the Document is released under this
4478 License. If a section does not fit the above definition of
4479 Secondary then it is not allowed to be designated as Invariant.
4480 The Document may contain zero Invariant Sections. If the Document
4481 does not identify any Invariant Sections then there are none.
4483 The "Cover Texts" are certain short passages of text that are
4484 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4485 that says that the Document is released under this License. A
4486 Front-Cover Text may be at most 5 words, and a Back-Cover Text may
4487 be at most 25 words.
4489 A "Transparent" copy of the Document means a machine-readable copy,
4490 represented in a format whose specification is available to the
4491 general public, that is suitable for revising the document
4492 straightforwardly with generic text editors or (for images
4493 composed of pixels) generic paint programs or (for drawings) some
4494 widely available drawing editor, and that is suitable for input to
4495 text formatters or for automatic translation to a variety of
4496 formats suitable for input to text formatters. A copy made in an
4497 otherwise Transparent file format whose markup, or absence of
4498 markup, has been arranged to thwart or discourage subsequent
4499 modification by readers is not Transparent. An image format is
4500 not Transparent if used for any substantial amount of text. A
4501 copy that is not "Transparent" is called "Opaque".
4503 Examples of suitable formats for Transparent copies include plain
4504 ASCII without markup, Texinfo input format, LaTeX input format,
4505 SGML or XML using a publicly available DTD, and
4506 standard-conforming simple HTML, PostScript or PDF designed for
4507 human modification. Examples of transparent image formats include
4508 PNG, XCF and JPG. Opaque formats include proprietary formats that
4509 can be read and edited only by proprietary word processors, SGML or
4510 XML for which the DTD and/or processing tools are not generally
4511 available, and the machine-generated HTML, PostScript or PDF
4512 produced by some word processors for output purposes only.
4514 The "Title Page" means, for a printed book, the title page itself,
4515 plus such following pages as are needed to hold, legibly, the
4516 material this License requires to appear in the title page. For
4517 works in formats which do not have any title page as such, "Title
4518 Page" means the text near the most prominent appearance of the
4519 work's title, preceding the beginning of the body of the text.
4521 A section "Entitled XYZ" means a named subunit of the Document
4522 whose title either is precisely XYZ or contains XYZ in parentheses
4523 following text that translates XYZ in another language. (Here XYZ
4524 stands for a specific section name mentioned below, such as
4525 "Acknowledgements", "Dedications", "Endorsements", or "History".)
4526 To "Preserve the Title" of such a section when you modify the
4527 Document means that it remains a section "Entitled XYZ" according
4530 The Document may include Warranty Disclaimers next to the notice
4531 which states that this License applies to the Document. These
4532 Warranty Disclaimers are considered to be included by reference in
4533 this License, but only as regards disclaiming warranties: any other
4534 implication that these Warranty Disclaimers may have is void and
4535 has no effect on the meaning of this License.
4539 You may copy and distribute the Document in any medium, either
4540 commercially or noncommercially, provided that this License, the
4541 copyright notices, and the license notice saying this License
4542 applies to the Document are reproduced in all copies, and that you
4543 add no other conditions whatsoever to those of this License. You
4544 may not use technical measures to obstruct or control the reading
4545 or further copying of the copies you make or distribute. However,
4546 you may accept compensation in exchange for copies. If you
4547 distribute a large enough number of copies you must also follow
4548 the conditions in section 3.
4550 You may also lend copies, under the same conditions stated above,
4551 and you may publicly display copies.
4553 3. COPYING IN QUANTITY
4555 If you publish printed copies (or copies in media that commonly
4556 have printed covers) of the Document, numbering more than 100, and
4557 the Document's license notice requires Cover Texts, you must
4558 enclose the copies in covers that carry, clearly and legibly, all
4559 these Cover Texts: Front-Cover Texts on the front cover, and
4560 Back-Cover Texts on the back cover. Both covers must also clearly
4561 and legibly identify you as the publisher of these copies. The
4562 front cover must present the full title with all words of the
4563 title equally prominent and visible. You may add other material
4564 on the covers in addition. Copying with changes limited to the
4565 covers, as long as they preserve the title of the Document and
4566 satisfy these conditions, can be treated as verbatim copying in
4569 If the required texts for either cover are too voluminous to fit
4570 legibly, you should put the first ones listed (as many as fit
4571 reasonably) on the actual cover, and continue the rest onto
4574 If you publish or distribute Opaque copies of the Document
4575 numbering more than 100, you must either include a
4576 machine-readable Transparent copy along with each Opaque copy, or
4577 state in or with each Opaque copy a computer-network location from
4578 which the general network-using public has access to download
4579 using public-standard network protocols a complete Transparent
4580 copy of the Document, free of added material. If you use the
4581 latter option, you must take reasonably prudent steps, when you
4582 begin distribution of Opaque copies in quantity, to ensure that
4583 this Transparent copy will remain thus accessible at the stated
4584 location until at least one year after the last time you
4585 distribute an Opaque copy (directly or through your agents or
4586 retailers) of that edition to the public.
4588 It is requested, but not required, that you contact the authors of
4589 the Document well before redistributing any large number of
4590 copies, to give them a chance to provide you with an updated
4591 version of the Document.
4595 You may copy and distribute a Modified Version of the Document
4596 under the conditions of sections 2 and 3 above, provided that you
4597 release the Modified Version under precisely this License, with
4598 the Modified Version filling the role of the Document, thus
4599 licensing distribution and modification of the Modified Version to
4600 whoever possesses a copy of it. In addition, you must do these
4601 things in the Modified Version:
4603 A. Use in the Title Page (and on the covers, if any) a title
4604 distinct from that of the Document, and from those of
4605 previous versions (which should, if there were any, be listed
4606 in the History section of the Document). You may use the
4607 same title as a previous version if the original publisher of
4608 that version gives permission.
4610 B. List on the Title Page, as authors, one or more persons or
4611 entities responsible for authorship of the modifications in
4612 the Modified Version, together with at least five of the
4613 principal authors of the Document (all of its principal
4614 authors, if it has fewer than five), unless they release you
4615 from this requirement.
4617 C. State on the Title page the name of the publisher of the
4618 Modified Version, as the publisher.
4620 D. Preserve all the copyright notices of the Document.
4622 E. Add an appropriate copyright notice for your modifications
4623 adjacent to the other copyright notices.
4625 F. Include, immediately after the copyright notices, a license
4626 notice giving the public permission to use the Modified
4627 Version under the terms of this License, in the form shown in
4630 G. Preserve in that license notice the full lists of Invariant
4631 Sections and required Cover Texts given in the Document's
4634 H. Include an unaltered copy of this License.
4636 I. Preserve the section Entitled "History", Preserve its Title,
4637 and add to it an item stating at least the title, year, new
4638 authors, and publisher of the Modified Version as given on
4639 the Title Page. If there is no section Entitled "History" in
4640 the Document, create one stating the title, year, authors,
4641 and publisher of the Document as given on its Title Page,
4642 then add an item describing the Modified Version as stated in
4643 the previous sentence.
4645 J. Preserve the network location, if any, given in the Document
4646 for public access to a Transparent copy of the Document, and
4647 likewise the network locations given in the Document for
4648 previous versions it was based on. These may be placed in
4649 the "History" section. You may omit a network location for a
4650 work that was published at least four years before the
4651 Document itself, or if the original publisher of the version
4652 it refers to gives permission.
4654 K. For any section Entitled "Acknowledgements" or "Dedications",
4655 Preserve the Title of the section, and preserve in the
4656 section all the substance and tone of each of the contributor
4657 acknowledgements and/or dedications given therein.
4659 L. Preserve all the Invariant Sections of the Document,
4660 unaltered in their text and in their titles. Section numbers
4661 or the equivalent are not considered part of the section
4664 M. Delete any section Entitled "Endorsements". Such a section
4665 may not be included in the Modified Version.
4667 N. Do not retitle any existing section to be Entitled
4668 "Endorsements" or to conflict in title with any Invariant
4671 O. Preserve any Warranty Disclaimers.
4673 If the Modified Version includes new front-matter sections or
4674 appendices that qualify as Secondary Sections and contain no
4675 material copied from the Document, you may at your option
4676 designate some or all of these sections as invariant. To do this,
4677 add their titles to the list of Invariant Sections in the Modified
4678 Version's license notice. These titles must be distinct from any
4679 other section titles.
4681 You may add a section Entitled "Endorsements", provided it contains
4682 nothing but endorsements of your Modified Version by various
4683 parties--for example, statements of peer review or that the text
4684 has been approved by an organization as the authoritative
4685 definition of a standard.
4687 You may add a passage of up to five words as a Front-Cover Text,
4688 and a passage of up to 25 words as a Back-Cover Text, to the end
4689 of the list of Cover Texts in the Modified Version. Only one
4690 passage of Front-Cover Text and one of Back-Cover Text may be
4691 added by (or through arrangements made by) any one entity. If the
4692 Document already includes a cover text for the same cover,
4693 previously added by you or by arrangement made by the same entity
4694 you are acting on behalf of, you may not add another; but you may
4695 replace the old one, on explicit permission from the previous
4696 publisher that added the old one.
4698 The author(s) and publisher(s) of the Document do not by this
4699 License give permission to use their names for publicity for or to
4700 assert or imply endorsement of any Modified Version.
4702 5. COMBINING DOCUMENTS
4704 You may combine the Document with other documents released under
4705 this License, under the terms defined in section 4 above for
4706 modified versions, provided that you include in the combination
4707 all of the Invariant Sections of all of the original documents,
4708 unmodified, and list them all as Invariant Sections of your
4709 combined work in its license notice, and that you preserve all
4710 their Warranty Disclaimers.
4712 The combined work need only contain one copy of this License, and
4713 multiple identical Invariant Sections may be replaced with a single
4714 copy. If there are multiple Invariant Sections with the same name
4715 but different contents, make the title of each such section unique
4716 by adding at the end of it, in parentheses, the name of the
4717 original author or publisher of that section if known, or else a
4718 unique number. Make the same adjustment to the section titles in
4719 the list of Invariant Sections in the license notice of the
4722 In the combination, you must combine any sections Entitled
4723 "History" in the various original documents, forming one section
4724 Entitled "History"; likewise combine any sections Entitled
4725 "Acknowledgements", and any sections Entitled "Dedications". You
4726 must delete all sections Entitled "Endorsements."
4728 6. COLLECTIONS OF DOCUMENTS
4730 You may make a collection consisting of the Document and other
4731 documents released under this License, and replace the individual
4732 copies of this License in the various documents with a single copy
4733 that is included in the collection, provided that you follow the
4734 rules of this License for verbatim copying of each of the
4735 documents in all other respects.
4737 You may extract a single document from such a collection, and
4738 distribute it individually under this License, provided you insert
4739 a copy of this License into the extracted document, and follow
4740 this License in all other respects regarding verbatim copying of
4743 7. AGGREGATION WITH INDEPENDENT WORKS
4745 A compilation of the Document or its derivatives with other
4746 separate and independent documents or works, in or on a volume of
4747 a storage or distribution medium, is called an "aggregate" if the
4748 copyright resulting from the compilation is not used to limit the
4749 legal rights of the compilation's users beyond what the individual
4750 works permit. When the Document is included an aggregate, this
4751 License does not apply to the other works in the aggregate which
4752 are not themselves derivative works of the Document.
4754 If the Cover Text requirement of section 3 is applicable to these
4755 copies of the Document, then if the Document is less than one half
4756 of the entire aggregate, the Document's Cover Texts may be placed
4757 on covers that bracket the Document within the aggregate, or the
4758 electronic equivalent of covers if the Document is in electronic
4759 form. Otherwise they must appear on printed covers that bracket
4760 the whole aggregate.
4764 Translation is considered a kind of modification, so you may
4765 distribute translations of the Document under the terms of section
4766 4. Replacing Invariant Sections with translations requires special
4767 permission from their copyright holders, but you may include
4768 translations of some or all Invariant Sections in addition to the
4769 original versions of these Invariant Sections. You may include a
4770 translation of this License, and all the license notices in the
4771 Document, and any Warrany Disclaimers, provided that you also
4772 include the original English version of this License and the
4773 original versions of those notices and disclaimers. In case of a
4774 disagreement between the translation and the original version of
4775 this License or a notice or disclaimer, the original version will
4778 If a section in the Document is Entitled "Acknowledgements",
4779 "Dedications", or "History", the requirement (section 4) to
4780 Preserve its Title (section 1) will typically require changing the
4785 You may not copy, modify, sublicense, or distribute the Document
4786 except as expressly provided for under this License. Any other
4787 attempt to copy, modify, sublicense or distribute the Document is
4788 void, and will automatically terminate your rights under this
4789 License. However, parties who have received copies, or rights,
4790 from you under this License will not have their licenses
4791 terminated so long as such parties remain in full compliance.
4793 10. FUTURE REVISIONS OF THIS LICENSE
4795 The Free Software Foundation may publish new, revised versions of
4796 the GNU Free Documentation License from time to time. Such new
4797 versions will be similar in spirit to the present version, but may
4798 differ in detail to address new problems or concerns. See
4799 `http://www.gnu.org/copyleft/'.
4801 Each version of the License is given a distinguishing version
4802 number. If the Document specifies that a particular numbered
4803 version of this License "or any later version" applies to it, you
4804 have the option of following the terms and conditions either of
4805 that specified version or of any later version that has been
4806 published (not as a draft) by the Free Software Foundation. If
4807 the Document does not specify a version number of this License,
4808 you may choose any version ever published (not as a draft) by the
4809 Free Software Foundation.
4811 ADDENDUM: How to use this License for your documents
4812 ====================================================
4814 To use this License in a document you have written, include a copy of
4815 the License in the document and put the following copyright and license
4816 notices just after the title page:
4818 Copyright (C) YEAR YOUR NAME.
4819 Permission is granted to copy, distribute and/or modify this document
4820 under the terms of the GNU Free Documentation License, Version 1.2
4821 or any later version published by the Free Software Foundation;
4822 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
4823 A copy of the license is included in the section entitled ``GNU
4824 Free Documentation License''.
4826 If you have Invariant Sections, Front-Cover Texts and Back-Cover
4827 Texts, replace the "with...Texts." line with this:
4829 with the Invariant Sections being LIST THEIR TITLES, with
4830 the Front-Cover Texts being LIST, and with the Back-Cover Texts
4833 If you have Invariant Sections without Cover Texts, or some other
4834 combination of the three, merge those two alternatives to suit the
4837 If your document contains nontrivial examples of program code, we
4838 recommend releasing these examples in parallel under your choice of
4839 free software license, such as the GNU General Public License, to
4840 permit their use in free software.
4843 File: cpp.info, Node: Index of Directives, Next: Option Index, Prev: GNU Free Documentation License, Up: Top
4851 * #assert: Assertions. (line 41)
4852 * #define: Object-like Macros. (line 11)
4853 * #elif: Elif. (line 6)
4854 * #else: Else. (line 6)
4855 * #endif: Ifdef. (line 6)
4856 * #error: Diagnostics. (line 6)
4857 * #ident: Other Directives. (line 6)
4858 * #if: Conditional Syntax. (line 6)
4859 * #ifdef: Ifdef. (line 6)
4860 * #ifndef: Ifdef. (line 40)
4861 * #import: Obsolete once-only headers.
4863 * #include: Include Syntax. (line 6)
4864 * #include_next: Wrapper Headers. (line 6)
4865 * #line: Line Control. (line 20)
4866 * #pragma GCC dependency: Pragmas. (line 53)
4867 * #pragma GCC poison: Pragmas. (line 65)
4868 * #pragma GCC system_header <1>: Pragmas. (line 92)
4869 * #pragma GCC system_header: System Headers. (line 31)
4870 * #sccs: Other Directives. (line 13)
4871 * #unassert: Assertions. (line 52)
4872 * #undef: Undefining and Redefining Macros.
4874 * #warning: Diagnostics. (line 27)
4877 File: cpp.info, Node: Option Index, Next: Concept Index, Prev: Index of Directives, Up: Top
4882 CPP's command line options and environment variables are indexed here
4883 without any initial `-' or `--'.
4888 * A: Invocation. (line 481)
4889 * ansi: Invocation. (line 307)
4890 * C: Invocation. (line 529)
4891 * C_INCLUDE_PATH: Environment Variables.
4893 * CPATH: Environment Variables.
4895 * CPLUS_INCLUDE_PATH: Environment Variables.
4897 * D: Invocation. (line 39)
4898 * dD: Invocation. (line 509)
4899 * DEPENDENCIES_OUTPUT: Environment Variables.
4901 * dI: Invocation. (line 518)
4902 * dM: Invocation. (line 497)
4903 * dN: Invocation. (line 515)
4904 * fdollars-in-identifiers: Invocation. (line 416)
4905 * fexec-charset: Invocation. (line 438)
4906 * finput-charset: Invocation. (line 451)
4907 * fno-show-column: Invocation. (line 476)
4908 * fno-working-directory: Invocation. (line 461)
4909 * fpreprocessed: Invocation. (line 419)
4910 * ftabstop: Invocation. (line 432)
4911 * fwide-exec-charset: Invocation. (line 443)
4912 * fworking-directory: Invocation. (line 461)
4913 * H: Invocation. (line 574)
4914 * help: Invocation. (line 566)
4915 * I: Invocation. (line 71)
4916 * I-: Invocation. (line 344)
4917 * idirafter: Invocation. (line 386)
4918 * imacros: Invocation. (line 377)
4919 * include: Invocation. (line 366)
4920 * iprefix: Invocation. (line 391)
4921 * iquote: Invocation. (line 410)
4922 * isystem: Invocation. (line 403)
4923 * iwithprefix: Invocation. (line 397)
4924 * iwithprefixbefore: Invocation. (line 397)
4925 * M: Invocation. (line 181)
4926 * MD: Invocation. (line 269)
4927 * MF: Invocation. (line 215)
4928 * MG: Invocation. (line 224)
4929 * MM: Invocation. (line 205)
4930 * MMD: Invocation. (line 284)
4931 * MP: Invocation. (line 234)
4932 * MQ: Invocation. (line 260)
4933 * MT: Invocation. (line 246)
4934 * nostdinc: Invocation. (line 356)
4935 * nostdinc++: Invocation. (line 361)
4936 * o: Invocation. (line 80)
4937 * OBJC_INCLUDE_PATH: Environment Variables.
4939 * P: Invocation. (line 522)
4940 * pedantic: Invocation. (line 171)
4941 * pedantic-errors: Invocation. (line 176)
4942 * remap: Invocation. (line 561)
4943 * std=: Invocation. (line 307)
4944 * SUNPRO_DEPENDENCIES: Environment Variables.
4946 * target-help: Invocation. (line 566)
4947 * traditional-cpp: Invocation. (line 554)
4948 * trigraphs: Invocation. (line 558)
4949 * U: Invocation. (line 62)
4950 * undef: Invocation. (line 66)
4951 * v: Invocation. (line 570)
4952 * version: Invocation. (line 583)
4953 * w: Invocation. (line 167)
4954 * Wall: Invocation. (line 86)
4955 * Wcomment: Invocation. (line 94)
4956 * Wcomments: Invocation. (line 94)
4957 * Wendif-labels: Invocation. (line 144)
4958 * Werror: Invocation. (line 157)
4959 * Wimport: Invocation. (line 117)
4960 * Wsystem-headers: Invocation. (line 161)
4961 * Wtraditional: Invocation. (line 111)
4962 * Wtrigraphs: Invocation. (line 99)
4963 * Wundef: Invocation. (line 120)
4964 * Wunused-macros: Invocation. (line 125)
4965 * x: Invocation. (line 291)
4968 File: cpp.info, Node: Concept Index, Prev: Option Index, Up: Top
4976 * # operator: Stringification. (line 6)
4977 * ## operator: Concatenation. (line 6)
4978 * _Pragma: Pragmas. (line 25)
4979 * alternative tokens: Tokenization. (line 105)
4980 * arguments: Macro Arguments. (line 6)
4981 * arguments in macro definitions: Macro Arguments. (line 6)
4982 * assertions: Assertions. (line 6)
4983 * assertions, canceling: Assertions. (line 52)
4984 * backslash-newline: Initial processing. (line 61)
4985 * block comments: Initial processing. (line 77)
4986 * C++ named operators: C++ Named Operators. (line 6)
4987 * character constants: Tokenization. (line 84)
4988 * character set, execution: Invocation. (line 438)
4989 * character set, input: Invocation. (line 451)
4990 * character set, wide execution: Invocation. (line 443)
4991 * command line: Invocation. (line 6)
4992 * commenting out code: Deleted Code. (line 6)
4993 * comments: Initial processing. (line 77)
4994 * common predefined macros: Common Predefined Macros.
4996 * computed includes: Computed Includes. (line 6)
4997 * concatenation: Concatenation. (line 6)
4998 * conditional group: Ifdef. (line 14)
4999 * conditionals: Conditionals. (line 6)
5000 * continued lines: Initial processing. (line 61)
5001 * controlling macro: Once-Only Headers. (line 35)
5002 * defined: Defined. (line 6)
5003 * dependencies for make as output: Environment Variables.
5005 * dependencies, make: Invocation. (line 181)
5006 * diagnostic: Diagnostics. (line 6)
5007 * differences from previous versions: Differences from previous versions.
5009 * digraphs: Tokenization. (line 105)
5010 * directive line: The preprocessing language.
5012 * directive name: The preprocessing language.
5014 * directives: The preprocessing language.
5016 * empty macro arguments: Macro Arguments. (line 66)
5017 * environment variables: Environment Variables.
5019 * expansion of arguments: Argument Prescan. (line 6)
5020 * FDL, GNU Free Documentation License: GNU Free Documentation License.
5022 * function-like macros: Function-like Macros.
5024 * grouping options: Invocation. (line 34)
5025 * guard macro: Once-Only Headers. (line 35)
5026 * header file: Header Files. (line 6)
5027 * header file names: Tokenization. (line 84)
5028 * identifiers: Tokenization. (line 34)
5029 * implementation limits: Implementation limits.
5031 * implementation-defined behavior: Implementation-defined behavior.
5033 * including just once: Once-Only Headers. (line 6)
5034 * invocation: Invocation. (line 6)
5035 * iso646.h: C++ Named Operators. (line 6)
5036 * line comments: Initial processing. (line 77)
5037 * line control: Line Control. (line 6)
5038 * line endings: Initial processing. (line 14)
5039 * linemarkers: Preprocessor Output. (line 28)
5040 * macro argument expansion: Argument Prescan. (line 6)
5041 * macro arguments and directives: Directives Within Macro Arguments.
5043 * macros in include: Computed Includes. (line 6)
5044 * macros with arguments: Macro Arguments. (line 6)
5045 * macros with variable arguments: Variadic Macros. (line 6)
5046 * make: Invocation. (line 181)
5047 * manifest constants: Object-like Macros. (line 6)
5048 * named operators: C++ Named Operators. (line 6)
5049 * newlines in macro arguments: Newlines in Arguments.
5051 * null directive: Other Directives. (line 18)
5052 * numbers: Tokenization. (line 60)
5053 * object-like macro: Object-like Macros. (line 6)
5054 * options: Invocation. (line 38)
5055 * options, grouping: Invocation. (line 34)
5056 * other tokens: Tokenization. (line 119)
5057 * output format: Preprocessor Output. (line 12)
5058 * overriding a header file: Wrapper Headers. (line 6)
5059 * parentheses in macro bodies: Operator Precedence Problems.
5061 * pitfalls of macros: Macro Pitfalls. (line 6)
5062 * predefined macros: Predefined Macros. (line 6)
5063 * predefined macros, system-specific: System-specific Predefined Macros.
5065 * predicates: Assertions. (line 19)
5066 * preprocessing directives: The preprocessing language.
5068 * preprocessing numbers: Tokenization. (line 60)
5069 * preprocessing tokens: Tokenization. (line 6)
5070 * prescan of macro arguments: Argument Prescan. (line 6)
5071 * problems with macros: Macro Pitfalls. (line 6)
5072 * punctuators: Tokenization. (line 105)
5073 * redefining macros: Undefining and Redefining Macros.
5075 * repeated inclusion: Once-Only Headers. (line 6)
5076 * reporting errors: Diagnostics. (line 6)
5077 * reporting warnings: Diagnostics. (line 6)
5078 * reserved namespace: System-specific Predefined Macros.
5080 * self-reference: Self-Referential Macros.
5082 * semicolons (after macro calls): Swallowing the Semicolon.
5084 * side effects (in macro arguments): Duplication of Side Effects.
5086 * standard predefined macros.: Standard Predefined Macros.
5088 * string constants: Tokenization. (line 84)
5089 * string literals: Tokenization. (line 84)
5090 * stringification: Stringification. (line 6)
5091 * symbolic constants: Object-like Macros. (line 6)
5092 * system header files <1>: System Headers. (line 6)
5093 * system header files: Header Files. (line 13)
5094 * system-specific predefined macros: System-specific Predefined Macros.
5096 * testing predicates: Assertions. (line 30)
5097 * token concatenation: Concatenation. (line 6)
5098 * token pasting: Concatenation. (line 6)
5099 * tokens: Tokenization. (line 6)
5100 * trigraphs: Initial processing. (line 32)
5101 * undefining macros: Undefining and Redefining Macros.
5103 * unsafe macros: Duplication of Side Effects.
5105 * variable number of arguments: Variadic Macros. (line 6)
5106 * variadic macros: Variadic Macros. (line 6)
5107 * wrapper #ifndef: Once-Only Headers. (line 6)
5108 * wrapper headers: Wrapper Headers. (line 6)
5114 Node: Overview
\x7f3769
5115 Node: Character sets
\x7f6590
5116 Ref: Character sets-Footnote-1
\x7f9049
5117 Node: Initial processing
\x7f9230
5118 Ref: trigraphs
\x7f10789
5119 Node: Tokenization
\x7f14991
5120 Ref: Tokenization-Footnote-1
\x7f22046
5121 Node: The preprocessing language
\x7f22157
5122 Node: Header Files
\x7f25035
5123 Node: Include Syntax
\x7f26915
5124 Node: Include Operation
\x7f28552
5125 Node: Search Path
\x7f30400
5126 Node: Once-Only Headers
\x7f33590
5127 Node: Computed Includes
\x7f35235
5128 Node: Wrapper Headers
\x7f38379
5129 Node: System Headers
\x7f40805
5130 Node: Macros
\x7f42855
5131 Node: Object-like Macros
\x7f43996
5132 Node: Function-like Macros
\x7f47586
5133 Node: Macro Arguments
\x7f49202
5134 Node: Stringification
\x7f53347
5135 Node: Concatenation
\x7f56553
5136 Node: Variadic Macros
\x7f59661
5137 Node: Predefined Macros
\x7f64448
5138 Node: Standard Predefined Macros
\x7f65036
5139 Node: Common Predefined Macros
\x7f70972
5140 Node: System-specific Predefined Macros
\x7f78925
5141 Node: C++ Named Operators
\x7f80946
5142 Node: Undefining and Redefining Macros
\x7f81910
5143 Node: Directives Within Macro Arguments
\x7f84014
5144 Node: Macro Pitfalls
\x7f85562
5145 Node: Misnesting
\x7f86095
5146 Node: Operator Precedence Problems
\x7f87207
5147 Node: Swallowing the Semicolon
\x7f89073
5148 Node: Duplication of Side Effects
\x7f91096
5149 Node: Self-Referential Macros
\x7f93279
5150 Node: Argument Prescan
\x7f95688
5151 Node: Newlines in Arguments
\x7f99442
5152 Node: Conditionals
\x7f100393
5153 Node: Conditional Uses
\x7f102223
5154 Node: Conditional Syntax
\x7f103581
5155 Node: Ifdef
\x7f103901
5157 Node: Defined
\x7f109366
5158 Node: Else
\x7f110649
5159 Node: Elif
\x7f111219
5160 Node: Deleted Code
\x7f112508
5161 Node: Diagnostics
\x7f113755
5162 Node: Line Control
\x7f115372
5163 Node: Pragmas
\x7f119176
5164 Node: Other Directives
\x7f123446
5165 Node: Preprocessor Output
\x7f124639
5166 Node: Traditional Mode
\x7f127840
5167 Node: Traditional lexical analysis
\x7f128898
5168 Node: Traditional macros
\x7f131401
5169 Node: Traditional miscellany
\x7f135203
5170 Node: Traditional warnings
\x7f136200
5171 Node: Implementation Details
\x7f138397
5172 Node: Implementation-defined behavior
\x7f139018
5173 Ref: Identifier characters
\x7f139755
5174 Node: Implementation limits
\x7f142676
5175 Node: Obsolete Features
\x7f145350
5176 Node: Assertions
\x7f145805
5177 Node: Obsolete once-only headers
\x7f148346
5178 Node: Differences from previous versions
\x7f150081
5179 Node: Invocation
\x7f154289
5180 Ref: Wtrigraphs
\x7f158620
5181 Ref: dashMF
\x7f163404
5182 Ref: fdollars-in-identifiers
\x7f171164
5183 Node: Environment Variables
\x7f178622
5184 Node: GNU Free Documentation License
\x7f181588
5185 Node: Index of Directives
\x7f204011
5186 Node: Option Index
\x7f205940
5187 Node: Concept Index
\x7f211832