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