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