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