OSDN Git Service

* cpp.texi: Clarify #pragma GCC namespace.
[pf3gnuchains/gcc-fork.git] / gcc / cpp.texi
1 \input texinfo
2 @setfilename cpp.info
3 @settitle The C Preprocessor
4
5 @ifinfo
6 @dircategory Programming
7 @direntry
8 * Cpp: (cpp).                  The GNU C preprocessor.
9 @end direntry
10 @end ifinfo
11
12 @c @smallbook
13 @c @cropmarks
14 @c @finalout
15 @setchapternewpage odd
16 @ifinfo
17 This file documents the GNU C Preprocessor.
18
19 Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
20 1999 Free Software Foundation, Inc.
21
22 Permission is granted to make and distribute verbatim copies of
23 this manual provided the copyright notice and this permission notice
24 are preserved on all copies.
25
26 @ignore
27 Permission is granted to process this file through Tex and print the
28 results, provided the printed document carries copying permission
29 notice identical to this one except for the removal of this paragraph
30 (this paragraph not being relevant to the printed manual).
31
32 @end ignore
33 Permission is granted to copy and distribute modified versions of this
34 manual under the conditions for verbatim copying, provided also that
35 the entire resulting derived work is distributed under the terms of a
36 permission notice identical to this one.
37
38 Permission is granted to copy and distribute translations of this manual
39 into another language, under the above conditions for modified versions.
40 @end ifinfo
41
42 @titlepage
43 @c @finalout
44 @title The C Preprocessor
45 @subtitle Last revised May 1999
46 @subtitle for GCC version 2
47 @author Richard M. Stallman
48 @page
49 @vskip 2pc
50 This booklet is eventually intended to form the first chapter of a GNU 
51 C Language manual.
52
53 @vskip 0pt plus 1filll
54 @c man begin COPYRIGHT
55 Copyright @copyright{} 1987, 1989, 1991-1999
56 Free Software Foundation, Inc.
57
58 Permission is granted to make and distribute verbatim copies of
59 this manual provided the copyright notice and this permission notice
60 are preserved on all copies.
61
62 Permission is granted to copy and distribute modified versions of this
63 manual under the conditions for verbatim copying, provided also that
64 the entire resulting derived work is distributed under the terms of a
65 permission notice identical to this one.
66
67 Permission is granted to copy and distribute translations of this manual
68 into another language, under the above conditions for modified versions.
69 @c man end
70 @end titlepage
71 @page
72
73 @node Top, Global Actions,, (DIR)
74 @chapter The C Preprocessor
75 @c man begin DESCRIPTION
76
77 The C preprocessor is a @dfn{macro processor} that is used automatically by
78 the C compiler to transform your program before actual compilation.  It is
79 called a macro processor because it allows you to define @dfn{macros},
80 which are brief abbreviations for longer constructs.
81
82 The C preprocessor provides four separate facilities that you can use as
83 you see fit:
84
85 @itemize @bullet
86 @item
87 Inclusion of header files.  These are files of declarations that can be
88 substituted into your program.
89
90 @item
91 Macro expansion.  You can define @dfn{macros}, which are abbreviations
92 for arbitrary fragments of C code, and then the C preprocessor will
93 replace the macros with their definitions throughout the program.
94
95 @item
96 Conditional compilation.  Using special preprocessing directives, you
97 can include or exclude parts of the program according to various
98 conditions.
99
100 @item
101 Line control.  If you use a program to combine or rearrange source files into
102 an intermediate file which is then compiled, you can use line control
103 to inform the compiler of where each source line originally came from.
104 @end itemize
105
106 C preprocessors vary in some details.  This manual discusses the GNU C
107 preprocessor, the C Compatible Compiler Preprocessor.  The GNU C
108 preprocessor provides a superset of the features of ANSI Standard C@.
109
110 ANSI Standard C requires the rejection of many harmless constructs commonly
111 used by today's C programs.  Such incompatibility would be inconvenient for
112 users, so the GNU C preprocessor is configured to accept these constructs
113 by default.  Strictly speaking, to get ANSI Standard C, you must use the
114 options @samp{-trigraphs}, @samp{-undef} and @samp{-pedantic}, but in
115 practice the consequences of having strict ANSI Standard C make it
116 undesirable to do this.  @xref{Invocation}.
117
118 The C preprocessor is designed for C-like languages; you may run into
119 problems if you apply it to other kinds of languages, because it assumes
120 that it is dealing with C@.  For example, the C preprocessor sometimes
121 outputs extra white space to avoid inadvertent C token concatenation,
122 and this may cause problems with other languages.
123 @c man end
124
125 @menu
126 * Global Actions::    Actions made uniformly on all input files.
127 * Directives::        General syntax of preprocessing directives.
128 * Header Files::      How and why to use header files.
129 * Macros::            How and why to use macros.
130 * Conditionals::      How and why to use conditionals.
131 * Combining Sources:: Use of line control when you combine source files.
132 * Other Directives::  Miscellaneous preprocessing directives.
133 * Output::            Format of output from the C preprocessor.
134 * Invocation::        How to invoke the preprocessor; command options.
135 * Concept Index::     Index of concepts and terms.
136 * Index::             Index of directives, predefined macros and options.
137 @end menu
138
139 @node Global Actions, Directives, Top, Top
140 @section Transformations Made Globally
141 @cindex ASCII NUL handling
142
143 Most C preprocessor features are inactive unless you give specific directives
144 to request their use.  (Preprocessing directives are lines starting with
145 @samp{#}; @pxref{Directives}).  But there are three transformations that the
146 preprocessor always makes on all the input it receives, even in the absence
147 of directives.
148
149 @itemize @bullet
150 @item
151 All C comments are replaced with single spaces.
152
153 @item
154 Backslash-Newline sequences are deleted, no matter where.  This
155 feature allows you to break long lines for cosmetic purposes without
156 changing their meaning.
157
158 @item
159 Predefined macro names are replaced with their expansions
160 (@pxref{Predefined}).
161 @end itemize
162
163 The first two transformations are done @emph{before} nearly all other parsing
164 and before preprocessing directives are recognized.  Thus, for example, you
165 can split a line cosmetically with Backslash-Newline anywhere (except
166 when trigraphs are in use; see below).
167
168 @example
169 /*
170 */ # /*
171 */ defi\
172 ne FO\
173 O 10\
174 20
175 @end example
176
177 @noindent
178 is equivalent into @samp{#define FOO 1020}.  You can split even an escape
179 sequence with Backslash-Newline.  For example, you can split @code{"foo\bar"}
180 between the @samp{\} and the @samp{b} to get
181
182 @example
183 "foo\\
184 bar"
185 @end example
186
187 @noindent
188 This behavior is unclean: in all other contexts, a Backslash can be
189 inserted in a string constant as an ordinary character by writing a double
190 Backslash, and this creates an exception.  But the ANSI C standard requires
191 it.  (Strict ANSI C does not allow Newlines in string constants, so they
192 do not consider this a problem.)
193
194 But there are a few exceptions to all three transformations.
195
196 @itemize @bullet
197 @item
198 C comments and predefined macro names are not recognized inside a
199 @samp{#include} directive in which the file name is delimited with
200 @samp{<} and @samp{>}.
201
202 @item
203 C comments and predefined macro names are never recognized within a
204 character or string constant.  (Strictly speaking, this is the rule,
205 not an exception, but it is worth noting here anyway.)
206
207 @item
208 Backslash-Newline may not safely be used within an ANSI ``trigraph''.
209 Trigraphs are converted before Backslash-Newline is deleted.  If you
210 write what looks like a trigraph with a Backslash-Newline inside, the
211 Backslash-Newline is deleted as usual, but it is then too late to
212 recognize the trigraph.
213
214 This exception is relevant only if you use the @samp{-trigraphs}
215 option to enable trigraph processing.  @xref{Invocation}.
216 @end itemize
217
218 The preprocessor handles null characters embedded in the input file
219 depending upon the context in which the null appears.  Note that here we
220 are referring not to the two-character escape sequence "\0", but to the
221 single character ASCII NUL.
222
223 There are three different contexts in which a null character may
224 appear:-
225
226 @itemize @bullet
227 @item
228 Within comments.  Here, null characters are silently ignored.
229
230 @item
231 Within a string or character constant.  Here the preprocessor emits a
232 warning, but preserves the null character and passes it through to the
233 output file.
234
235 @item
236 In any other context, the preprocessor issues a warning, and discards
237 the null character.  In all other respects the preprocessor treats it
238 like whitespace, combining it with any surrounding whitespace to become
239 a single whitespace token.  Representing the null character by "^@@",
240 this means that code like
241
242 @example
243 #define X^@@1
244 @end example
245
246 is equivalent to
247
248 @example
249 #define X 1
250 @end example
251
252 and X is defined with replacement text "1".
253 @end itemize
254
255 @node Directives, Header Files, Global Actions, Top
256 @section Preprocessing Directives
257
258 @cindex preprocessing directives
259 @cindex directives
260 Most preprocessor features are active only if you use preprocessing directives
261 to request their use.
262
263 Preprocessing directives are lines in your program that start with @samp{#}.
264 The @samp{#} is followed by an identifier that is the @dfn{directive name}.
265 For example, @samp{#define} is the directive that defines a macro.
266 Whitespace is also allowed before and after the @samp{#}.
267
268 The set of valid directive names is fixed.  Programs cannot define new
269 preprocessing directives.
270
271 Some directive names require arguments; these make up the rest of the directive
272 line and must be separated from the directive name by whitespace.  For example,
273 @samp{#define} must be followed by a macro name and the intended expansion
274 of the macro.  @xref{Simple Macros}.
275
276 A preprocessing directive cannot be more than one line in normal circumstances.
277 It may be split cosmetically with Backslash-Newline, but that has no effect
278 on its meaning.  Comments containing Newlines can also divide the
279 directive into multiple lines, but the comments are changed to Spaces
280 before the directive is interpreted.  The only way a significant Newline
281 can occur in a preprocessing directive is within a string constant or
282 character constant.  Note that
283 most C compilers that might be applied to the output from the preprocessor
284 do not accept string or character constants containing Newlines.
285
286 The @samp{#} and the directive name cannot come from a macro expansion.  For
287 example, if @samp{foo} is defined as a macro expanding to @samp{define},
288 that does not make @samp{#foo} a valid preprocessing directive.
289
290 @node Header Files, Macros, Directives, Top
291 @section Header Files
292
293 @cindex header file
294 A header file is a file containing C declarations and macro definitions
295 (@pxref{Macros}) to be shared between several source files.  You request
296 the use of a header file in your program with the C preprocessing directive
297 @samp{#include}.
298
299 @menu
300 * Header Uses::         What header files are used for.
301 * Include Syntax::      How to write @samp{#include} directives.
302 * Include Operation::   What @samp{#include} does.
303 * Once-Only::           Preventing multiple inclusion of one header file.
304 * Inheritance::         Including one header file in another header file.
305 * System Headers::      Special treatment for some header files.
306 @end menu
307
308 @node Header Uses, Include Syntax, Header Files, Header Files
309 @subsection Uses of Header Files
310
311 Header files serve two kinds of purposes.
312
313 @itemize @bullet
314 @item
315 @cindex system header files
316 System header files declare the interfaces to parts of the operating
317 system.  You include them in your program to supply the definitions and
318 declarations you need to invoke system calls and libraries.
319
320 @item
321 Your own header files contain declarations for interfaces between the
322 source files of your program.  Each time you have a group of related
323 declarations and macro definitions all or most of which are needed in
324 several different source files, it is a good idea to create a header
325 file for them.
326 @end itemize
327
328 Including a header file produces the same results in C compilation as
329 copying the header file into each source file that needs it.  But such
330 copying would be time-consuming and error-prone.  With a header file, the
331 related declarations appear in only one place.  If they need to be changed,
332 they can be changed in one place, and programs that include the header file
333 will automatically use the new version when next recompiled.  The header
334 file eliminates the labor of finding and changing all the copies as well as
335 the risk that a failure to find one copy will result in inconsistencies
336 within a program.
337
338 The usual convention is to give header files names that end with
339 @file{.h}.  Avoid unusual characters in header file names, as they
340 reduce portability.
341
342 @node Include Syntax, Include Operation, Header Uses, Header Files
343 @subsection The @samp{#include} Directive
344
345 @findex #include
346 Both user and system header files are included using the preprocessing
347 directive @samp{#include}.  It has three variants:
348
349 @table @code
350 @item #include <@var{file}>
351 This variant is used for system header files.  It searches for a file
352 named @var{file} in a list of directories specified by you, then in a
353 standard list of system directories.  You specify directories to
354 search for header files with the command option @samp{-I}
355 (@pxref{Invocation}).  The option @samp{-nostdinc} inhibits searching
356 the standard system directories; in this case only the directories
357 you specify are searched.
358
359 The parsing of this form of @samp{#include} is slightly special
360 because comments are not recognized within the @samp{<@dots{}>}.
361 Thus, in @samp{#include <x/*y>} the @samp{/*} does not start a comment
362 and the directive specifies inclusion of a system header file named
363 @file{x/*y}.  Of course, a header file with such a name is unlikely to
364 exist on Unix, where shell wildcard features would make it hard to
365 manipulate.@refill
366
367 The argument @var{file} may not contain a @samp{>} character.  It may,
368 however, contain a @samp{<} character.
369
370 @item #include "@var{file}"
371 This variant is used for header files of your own program.  It
372 searches for a file named @var{file} first in the current directory,
373 then in the same directories used for system header files.  The
374 current directory is the directory of the current input file.  It is
375 tried first because it is presumed to be the location of the files
376 that the current input file refers to.  (If the @samp{-I-} option is
377 used, the special treatment of the current directory is inhibited.)
378
379 The argument @var{file} may not contain @samp{"} characters.  If
380 backslashes occur within @var{file}, they are considered ordinary text
381 characters, not escape characters.  None of the character escape
382 sequences appropriate to string constants in C are processed.  Thus,
383 @samp{#include "x\n\\y"} specifies a filename containing three
384 backslashes.  It is not clear why this behavior is ever useful, but
385 the ANSI standard specifies it.
386
387 @item #include @var{anything else}
388 @cindex computed @samp{#include}
389 This variant is called a @dfn{computed #include}.  Any @samp{#include}
390 directive whose argument does not fit the above two forms is a computed
391 include.  The text @var{anything else} is checked for macro calls,
392 which are expanded (@pxref{Macros}).  When this is done, the result
393 must fit one of the above two variants---in particular, the expanded
394 text must in the end be surrounded by either quotes or angle braces.
395
396 This feature allows you to define a macro which controls the file name
397 to be used at a later point in the program.  One application of this is
398 to allow a site-specific configuration file for your program to specify
399 the names of the system include files to be used.  This can help in
400 porting the program to various operating systems in which the necessary
401 system header files are found in different places.
402 @end table
403
404 @node Include Operation, Once-Only, Include Syntax, Header Files
405 @subsection How @samp{#include} Works
406
407 The @samp{#include} directive works by directing the C preprocessor to scan
408 the specified file as input before continuing with the rest of the current
409 file.  The output from the preprocessor contains the output already
410 generated, followed by the output resulting from the included file,
411 followed by the output that comes from the text after the @samp{#include}
412 directive.  For example, given a header file @file{header.h} as follows,
413
414 @example
415 char *test ();
416 @end example
417
418 @noindent
419 and a main program called @file{program.c} that uses the header file,
420 like this,
421
422 @example
423 int x;
424 #include "header.h"
425
426 main ()
427 @{
428   printf (test ());
429 @}
430 @end example
431
432 @noindent
433 the output generated by the C preprocessor for @file{program.c} as input
434 would be
435
436 @example
437 int x;
438 char *test ();
439
440 main ()
441 @{
442   printf (test ());
443 @}
444 @end example
445
446 Included files are not limited to declarations and macro definitions; those
447 are merely the typical uses.  Any fragment of a C program can be included
448 from another file.  The include file could even contain the beginning of a
449 statement that is concluded in the containing file, or the end of a
450 statement that was started in the including file.  However, a comment or a
451 string or character constant may not start in the included file and finish
452 in the including file.  An unterminated comment, string constant or
453 character constant in an included file is considered to end (with an error
454 message) at the end of the file.
455
456 It is possible for a header file to begin or end a syntactic unit such
457 as a function definition, but that would be very confusing, so don't do
458 it.
459
460 The line following the @samp{#include} directive is always treated as a
461 separate line by the C preprocessor even if the included file lacks a final
462 newline.
463
464 @node Once-Only, Inheritance, Include Operation, Header Files
465 @subsection Once-Only Include Files
466 @cindex repeated inclusion
467 @cindex including just once
468
469 Very often, one header file includes another.  It can easily result that a
470 certain header file is included more than once.  This may lead to errors,
471 if the header file defines structure types or typedefs, and is certainly
472 wasteful.  Therefore, we often wish to prevent multiple inclusion of a
473 header file.
474
475 The standard way to do this is to enclose the entire real contents of the
476 file in a conditional, like this:
477
478 @example
479 #ifndef FILE_FOO_SEEN
480 #define FILE_FOO_SEEN
481
482 @var{the entire file}
483
484 #endif /* FILE_FOO_SEEN */
485 @end example
486
487 The macro @code{FILE_FOO_SEEN} indicates that the file has been included
488 once already.  In a user header file, the macro name should not begin
489 with @samp{_}.  In a system header file, this name should begin with
490 @samp{__} to avoid conflicts with user programs.  In any kind of header
491 file, the macro name should contain the name of the file and some
492 additional text, to avoid conflicts with other header files.
493
494 The GNU C preprocessor is programmed to notice when a header file uses
495 this particular construct and handle it efficiently.  If a header file
496 is contained entirely in a @samp{#ifndef} conditional, then it records
497 that fact.  If a subsequent @samp{#include} specifies the same file,
498 and the macro in the @samp{#ifndef} is already defined, then the file
499 is entirely skipped, without even reading it.
500
501 @findex #pragma once
502 There is also an explicit directive to tell the preprocessor that it need
503 not include a file more than once.  This is called @samp{#pragma once},
504 and was used @emph{in addition to} the @samp{#ifndef} conditional around
505 the contents of the header file.  @samp{#pragma once} is now obsolete
506 and should not be used at all.
507
508 @findex #import
509 In the Objective C language, there is a variant of @samp{#include}
510 called @samp{#import} which includes a file, but does so at most once.
511 If you use @samp{#import} @emph{instead of} @samp{#include}, then you
512 don't need the conditionals inside the header file to prevent multiple
513 execution of the contents.
514
515 @samp{#import} is obsolete because it is not a well designed feature.
516 It requires the users of a header file---the applications
517 programmers---to know that a certain header file should only be included
518 once.  It is much better for the header file's implementor to write the
519 file so that users don't need to know this.  Using @samp{#ifndef}
520 accomplishes this goal.
521
522 @node Inheritance, System Headers, Once-Only, Header Files
523 @subsection Inheritance and Header Files
524 @cindex inheritance
525 @cindex overriding a header file
526
527 @dfn{Inheritance} is what happens when one object or file derives some
528 of its contents by virtual copying from another object or file.  In
529 the case of C header files, inheritance means that one header file 
530 includes another header file and then replaces or adds something.
531
532 If the inheriting header file and the base header file have different
533 names, then inheritance is straightforward: simply write @samp{#include
534 "@var{base}"} in the inheriting file.
535
536 Sometimes it is necessary to give the inheriting file the same name as
537 the base file.  This is less straightforward.
538
539 For example, suppose an application program uses the system header
540 @file{sys/signal.h}, but the version of @file{/usr/include/sys/signal.h}
541 on a particular system doesn't do what the application program expects.
542 It might be convenient to define a ``local'' version, perhaps under the
543 name @file{/usr/local/include/sys/signal.h}, to override or add to the
544 one supplied by the system.
545
546 You can do this by compiling with the option @samp{-I.}, and
547 writing a file @file{sys/signal.h} that does what the application
548 program expects.  But making this file include the standard
549 @file{sys/signal.h} is not so easy---writing @samp{#include
550 <sys/signal.h>} in that file doesn't work, because it includes your own
551 version of the file, not the standard system version.  Used in that file
552 itself, this leads to an infinite recursion and a fatal error in
553 compilation.
554
555 @samp{#include </usr/include/sys/signal.h>} would find the proper file,
556 but that is not clean, since it makes an assumption about where the
557 system header file is found.  This is bad for maintenance, since it
558 means that any change in where the system's header files are kept
559 requires a change somewhere else.
560
561 @findex #include_next
562 The clean way to solve this problem is to use 
563 @samp{#include_next}, which means, ``Include the @emph{next} file with
564 this name.''  This directive works like @samp{#include} except in
565 searching for the specified file: it starts searching the list of header
566 file directories @emph{after} the directory in which the current file
567 was found.
568
569 Suppose you specify @samp{-I /usr/local/include}, and the list of
570 directories to search also includes @file{/usr/include}; and suppose
571 both directories contain @file{sys/signal.h}.  Ordinary
572 @samp{#include <sys/signal.h>} finds the file under
573 @file{/usr/local/include}.  If that file contains @samp{#include_next
574 <sys/signal.h>}, it starts searching after that directory, and finds the
575 file in @file{/usr/include}.
576
577 @samp{#include_next} is a GCC extension and should not be used in
578 programs intended to be portable to other compilers.
579
580 @node System Headers,, Inheritance, Header Files
581 @subsection System Headers
582 @cindex system header files
583
584 The header files declaring interfaces to the operating system and
585 runtime libraries often cannot be written in strictly conforming C.
586 Therefore, GNU C gives code found in @dfn{system headers} special
587 treatment.  Certain categories of warnings are suppressed, notably those
588 enabled by @samp{-pedantic}.  For example, a hypothetical definition of
589 @code{printf} as a variable argument macro:
590
591 @smallexample
592 #define printf(format, args...) fprintf(stdout, format , ##args)
593 @end smallexample
594
595 @noindent
596 would cause a warning with -pedantic if it appeared in your own code,
597 but not if it appeared in @file{stdio.h}.
598
599 Normally, only the headers found in specific directories are considered
600 system headers.  The set of these directories is determined when GCC is
601 compiled.  There are, however, two ways to add to the set.
602
603 @findex -isystem
604 The @samp{-isystem} command line option adds its argument to the list of
605 directories to search for headers, just like @samp{-I}.  In addition,
606 any headers found in that directory will be considered system headers.
607 Note that unlike @samp{-I}, you must put a space between @samp{-isystem}
608 and its argument.
609
610 All directories named by @samp{-isystem} are searched @strong{after} all
611 directories named by @samp{-I}, no matter what their order was on the
612 command line.  If the same directory is named by both @samp{-I} and
613 @samp{-isystem}, @samp{-I} wins; it is as if the @samp{-isystem} option
614 had never been specified at all.
615
616 @findex #pragma GCC system_header
617 There is also a directive, @samp{#pragma GCC system_header}, which tells GCC
618 to consider the rest of the current include file a system header, no
619 matter where it was found.  Code that comes before the @samp{#pragma} in
620 the file will not be affected.
621
622 @samp{#pragma GCC system_header} has no effect in the primary source file.
623
624 @node Macros, Conditionals, Header Files, Top
625 @section Macros
626
627 A macro is a sort of abbreviation which you can define once and then
628 use later.  There are many complicated features associated with macros
629 in the C preprocessor.
630
631 @menu
632 * Simple Macros::    Macros that always expand the same way.
633 * Argument Macros::  Macros that accept arguments that are substituted
634                        into the macro expansion.
635 * Macro Varargs::    Macros with variable number of arguments.
636 * Predefined::       Predefined macros that are always available.
637 * Stringification::  Macro arguments converted into string constants.
638 * Concatenation::    Building tokens from parts taken from macro arguments.
639 * Undefining::       Cancelling a macro's definition.
640 * Redefining::       Changing a macro's definition.
641 * Poisoning::        Ensuring a macro is never defined or used.
642 * Macro Pitfalls::   Macros can confuse the unwary.  Here we explain
643                        several common problems and strange features.
644 @end menu
645
646 @node Simple Macros, Argument Macros, Macros, Macros
647 @subsection Simple Macros
648 @cindex simple macro
649 @cindex manifest constant
650
651 A @dfn{simple macro} is a kind of abbreviation.  It is a name which
652 stands for a fragment of code.  Some people refer to these as
653 @dfn{manifest constants}.
654
655 Before you can use a macro, you must @dfn{define} it explicitly with the
656 @samp{#define} directive.  @samp{#define} is followed by the name of the
657 macro and then the code it should be an abbreviation for.  For example,
658
659 @example
660 #define BUFFER_SIZE 1020
661 @end example
662
663 @noindent
664 defines a macro named @samp{BUFFER_SIZE} as an abbreviation for the text
665 @samp{1020}.  If somewhere after this @samp{#define} directive there comes
666 a C statement of the form
667
668 @example
669 foo = (char *) xmalloc (BUFFER_SIZE);
670 @end example
671
672 @noindent
673 then the C preprocessor will recognize and @dfn{expand} the macro
674 @samp{BUFFER_SIZE}, resulting in
675
676 @example
677 foo = (char *) xmalloc (1020);
678 @end example
679
680 The use of all upper case for macro names is a standard convention.
681 Programs are easier to read when it is possible to tell at a glance which
682 names are macros.
683
684 Normally, a macro definition must be a single line, like all C
685 preprocessing directives.  (You can split a long macro definition
686 cosmetically with Backslash-Newline.)  There is one exception: Newlines
687 can be included in the macro definition if within a string or character
688 constant.  This is because it is not possible for a macro definition to
689 contain an unbalanced quote character; the definition automatically
690 extends to include the matching quote character that ends the string or
691 character constant.  Comments within a macro definition may contain
692 Newlines, which make no difference since the comments are entirely
693 replaced with Spaces regardless of their contents.
694
695 Aside from the above, there is no restriction on what can go in a macro
696 body.  Parentheses need not balance.  The body need not resemble valid C
697 code.  (But if it does not, you may get error messages from the C
698 compiler when you use the macro.)
699
700 The C preprocessor scans your program sequentially, so macro definitions
701 take effect at the place you write them.  Therefore, the following input to
702 the C preprocessor
703
704 @example
705 foo = X;
706 #define X 4
707 bar = X;
708 @end example
709
710 @noindent
711 produces as output
712
713 @example
714 foo = X;
715
716 bar = 4;
717 @end example
718
719 After the preprocessor expands a macro name, the macro's definition body is
720 appended to the front of the remaining input, and the check for macro calls
721 continues.  Therefore, the macro body can contain calls to other macros.
722 For example, after
723
724 @example
725 #define BUFSIZE 1020
726 #define TABLESIZE BUFSIZE
727 @end example
728
729 @noindent
730 the name @samp{TABLESIZE} when used in the program would go through two
731 stages of expansion, resulting ultimately in @samp{1020}.
732
733 This is not at all the same as defining @samp{TABLESIZE} to be @samp{1020}.
734 The @samp{#define} for @samp{TABLESIZE} uses exactly the body you
735 specify---in this case, @samp{BUFSIZE}---and does not check to see whether
736 it too is the name of a macro.  It's only when you @emph{use} @samp{TABLESIZE}
737 that the result of its expansion is checked for more macro names.
738 @xref{Cascaded Macros}.
739
740 @node Argument Macros, Macro Varargs, Simple Macros, Macros
741 @subsection Macros with Arguments
742 @cindex macros with argument
743 @cindex arguments in macro definitions
744 @cindex function-like macro
745
746 A simple macro always stands for exactly the same text, each time it is
747 used.  Macros can be more flexible when they accept @dfn{arguments}.
748 Arguments are fragments of code that you supply each time the macro is
749 used.  These fragments are included in the expansion of the macro
750 according to the directions in the macro definition.  A macro that
751 accepts arguments is called a @dfn{function-like macro} because the
752 syntax for using it looks like a function call.
753
754 @findex #define
755 To define a macro that uses arguments, you write a @samp{#define} directive
756 with a list of @dfn{argument names} in parentheses after the name of the
757 macro.  The argument names may be any valid C identifiers, separated by
758 commas and optionally whitespace.  The open-parenthesis must follow the
759 macro name immediately, with no space in between.
760
761 For example, here is a macro that computes the minimum of two numeric
762 values, as it is defined in many C programs:
763
764 @example
765 #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
766 @end example
767
768 @noindent
769 (This is not the best way to define a ``minimum'' macro in GNU C@.
770 @xref{Side Effects}, for more information.)
771
772 To use a macro that expects arguments, you write the name of the macro
773 followed by a list of @dfn{actual arguments} in parentheses, separated by
774 commas.  The number of actual arguments you give must match the number of
775 arguments the macro expects.   Examples of use of the macro @samp{min}
776 include @samp{min (1, 2)} and @samp{min (x + 28, *p)}.
777
778 The expansion text of the macro depends on the arguments you use.
779 Each of the argument names of the macro is replaced, throughout the
780 macro definition, with the corresponding actual argument.  Using the
781 same macro @samp{min} defined above, @samp{min (1, 2)} expands into
782
783 @example
784 ((1) < (2) ? (1) : (2))
785 @end example
786
787 @noindent
788 where @samp{1} has been substituted for @samp{X} and @samp{2} for @samp{Y}.
789
790 Likewise, @samp{min (x + 28, *p)} expands into
791
792 @example
793 ((x + 28) < (*p) ? (x + 28) : (*p))
794 @end example
795
796 Parentheses in the actual arguments must balance; a comma within
797 parentheses does not end an argument.  However, there is no requirement
798 for brackets or braces to balance, and they do not prevent a comma from
799 separating arguments.  Thus,
800
801 @example
802 macro (array[x = y, x + 1])
803 @end example
804
805 @noindent
806 passes two arguments to @code{macro}: @samp{array[x = y} and @samp{x +
807 1]}.  If you want to supply @samp{array[x = y, x + 1]} as an argument,
808 you must write it as @samp{array[(x = y, x + 1)]}, which is equivalent C
809 code.
810
811 After the actual arguments are substituted into the macro body, the entire
812 result is appended to the front of the remaining input, and the check for
813 macro calls continues.  Therefore, the actual arguments can contain calls
814 to other macros, either with or without arguments, or even to the same
815 macro.  The macro body can also contain calls to other macros.  For
816 example, @samp{min (min (a, b), c)} expands into this text:
817
818 @example
819 ((((a) < (b) ? (a) : (b))) < (c)
820  ? (((a) < (b) ? (a) : (b)))
821  : (c))
822 @end example
823
824 @noindent
825 (Line breaks shown here for clarity would not actually be generated.)
826
827 @cindex blank macro arguments
828 @cindex space as macro argument
829 If a macro @code{foo} takes one argument, and you want to supply an
830 empty argument, you must write at least some whitespace between the
831 parentheses, like this: @samp{foo ( )}.  Just @samp{foo ()} is providing
832 no arguments, which is an error if @code{foo} expects an argument.  But
833 @samp{foo0 ()} is the correct way to call a macro defined to take zero
834 arguments, like this:
835
836 @example
837 #define foo0() @dots{}
838 @end example
839
840 If you use the macro name followed by something other than an
841 open-parenthesis (after ignoring any spaces, tabs and comments that
842 follow), it is not a call to the macro, and the preprocessor does not
843 change what you have written.  Therefore, it is possible for the same name
844 to be a variable or function in your program as well as a macro, and you
845 can choose in each instance whether to refer to the macro (if an actual
846 argument list follows) or the variable or function (if an argument list
847 does not follow).
848
849 Such dual use of one name could be confusing and should be avoided
850 except when the two meanings are effectively synonymous: that is, when the
851 name is both a macro and a function and the two have similar effects.  You
852 can think of the name simply as a function; use of the name for purposes
853 other than calling it (such as, to take the address) will refer to the
854 function, while calls will expand the macro and generate better but
855 equivalent code.  For example, you can use a function named @samp{min} in
856 the same source file that defines the macro.  If you write @samp{&min} with
857 no argument list, you refer to the function.  If you write @samp{min (x,
858 bb)}, with an argument list, the macro is expanded.  If you write
859 @samp{(min) (a, bb)}, where the name @samp{min} is not followed by an
860 open-parenthesis, the macro is not expanded, so you wind up with a call to
861 the function @samp{min}.
862
863 You may not define the same name as both a simple macro and a macro with
864 arguments.
865
866 In the definition of a macro with arguments, the list of argument names
867 must follow the macro name immediately with no space in between.  If there
868 is a space after the macro name, the macro is defined as taking no
869 arguments, and all the rest of the line is taken to be the expansion.  The
870 reason for this is that it is often useful to define a macro that takes no
871 arguments and whose definition begins with an identifier in parentheses.
872 This rule about spaces makes it possible for you to do either this:
873
874 @example
875 #define FOO(x) - 1 / (x)
876 @end example
877
878 @noindent
879 (which defines @samp{FOO} to take an argument and expand into minus the
880 reciprocal of that argument) or this:
881
882 @example
883 #define BAR (x) - 1 / (x)
884 @end example
885
886 @noindent
887 (which defines @samp{BAR} to take no argument and always expand into
888 @samp{(x) - 1 / (x)}).
889
890 Note that the @emph{uses} of a macro with arguments can have spaces before
891 the left parenthesis; it's the @emph{definition} where it matters whether
892 there is a space.
893
894 @node Macro Varargs, Predefined, Argument Macros, Macros
895 @subsection Macros with Variable Numbers of Arguments
896 @cindex variable number of arguments
897 @cindex macro with variable arguments
898 @cindex rest argument (in macro)
899
900 In GNU C, a macro can accept a variable number of arguments, much as a
901 function can.  The syntax for defining the macro looks much like that
902 used for a function.  Here is an example:
903
904 @example
905 #define eprintf(format, args...)  \
906  fprintf (stderr, format , ## args)
907 @end example
908
909 Here @code{args} is a @dfn{rest argument}: it takes in zero or more
910 arguments, as many as the call contains.  All of them plus the commas
911 between them form the value of @code{args}, which is substituted into
912 the macro body where @code{args} is used.  Thus, we have this expansion:
913
914 @example
915 eprintf ("%s:%d: ", input_file_name, line_number)
916 @expansion{}
917 fprintf (stderr, "%s:%d: " , input_file_name, line_number)
918 @end example
919
920 @noindent
921 Note that the comma after the string constant comes from the definition
922 of @code{eprintf}, whereas the last comma comes from the value of
923 @code{args}.
924
925 The reason for using @samp{##} is to handle the case when @code{args}
926 matches no arguments at all.  In this case, @code{args} has an empty
927 value.  In this case, the second comma in the definition becomes an
928 embarrassment: if it got through to the expansion of the macro, we would
929 get something like this:
930
931 @example
932 fprintf (stderr, "success!\n" , )
933 @end example
934
935 @noindent
936 which is invalid C syntax.  @samp{##} gets rid of the comma, so we get
937 the following instead:
938
939 @example
940 fprintf (stderr, "success!\n")
941 @end example
942
943 This is a special feature of the GNU C preprocessor: @samp{##} before a
944 rest argument that is empty discards the preceding sequence of
945 non-whitespace characters from the macro definition.  (If another macro
946 argument precedes, none of it is discarded.)
947
948 It might be better to discard the last preprocessor token instead of the
949 last preceding sequence of non-whitespace characters; in fact, we may
950 someday change this feature to do so.  We advise you to write the macro
951 definition so that the preceding sequence of non-whitespace characters
952 is just a single token, so that the meaning will not change if we change
953 the definition of this feature.
954
955 @node Predefined, Stringification, Macro Varargs, Macros
956 @subsection Predefined Macros
957
958 @cindex predefined macros
959 Several simple macros are predefined.  You can use them without giving
960 definitions for them.  They fall into two classes: standard macros and
961 system-specific macros.
962
963 @menu
964 * Standard Predefined::     Standard predefined macros.
965 * Nonstandard Predefined::  Nonstandard predefined macros.
966 @end menu
967
968 @node Standard Predefined, Nonstandard Predefined, Predefined, Predefined
969 @subsubsection Standard Predefined Macros
970 @cindex standard predefined macros
971
972 The standard predefined macros are available with the same meanings
973 regardless of the machine or operating system on which you are using GNU C@.
974 Their names all start and end with double underscores.  Those preceding
975 @code{__GNUC__} in this table are standardized by ANSI C; the rest are
976 GNU C extensions.
977
978 @table @code
979 @item __FILE__
980 @findex __FILE__
981 This macro expands to the name of the current input file, in the form of
982 a C string constant.  The precise name returned is the one that was
983 specified in @samp{#include} or as the input file name argument.
984
985 @item __LINE__
986 @findex __LINE__
987 This macro expands to the current input line number, in the form of a
988 decimal integer constant.  While we call it a predefined macro, it's
989 a pretty strange macro, since its ``definition'' changes with each
990 new line of source code.
991
992 This and @samp{__FILE__} are useful in generating an error message to
993 report an inconsistency detected by the program; the message can state
994 the source line at which the inconsistency was detected.  For example,
995
996 @smallexample
997 fprintf (stderr, "Internal error: "
998                  "negative string length "
999                  "%d at %s, line %d.",
1000          length, __FILE__, __LINE__);
1001 @end smallexample
1002
1003 A @samp{#include} directive changes the expansions of @samp{__FILE__}
1004 and @samp{__LINE__} to correspond to the included file.  At the end of
1005 that file, when processing resumes on the input file that contained
1006 the @samp{#include} directive, the expansions of @samp{__FILE__} and
1007 @samp{__LINE__} revert to the values they had before the
1008 @samp{#include} (but @samp{__LINE__} is then incremented by one as
1009 processing moves to the line after the @samp{#include}).
1010
1011 The expansions of both @samp{__FILE__} and @samp{__LINE__} are altered
1012 if a @samp{#line} directive is used.  @xref{Combining Sources}.
1013
1014 @item __DATE__
1015 @findex __DATE__
1016 This macro expands to a string constant that describes the date on
1017 which the preprocessor is being run.  The string constant contains
1018 eleven characters and looks like @w{@samp{"Feb  1 1996"}}.
1019 @c After reformatting the above, check that the date remains `Feb  1 1996',
1020 @c all on one line, with two spaces between the `Feb' and the `1'.
1021
1022 @item __TIME__
1023 @findex __TIME__
1024 This macro expands to a string constant that describes the time at
1025 which the preprocessor is being run.  The string constant contains
1026 eight characters and looks like @samp{"23:59:01"}.
1027
1028 @item __STDC__
1029 @findex __STDC__
1030 This macro expands to the constant 1, to signify that this is ANSI
1031 Standard C@.  (Whether that is actually true depends on what C compiler
1032 will operate on the output from the preprocessor.)
1033
1034 On some hosts, system include files use a different convention, where
1035 @samp{__STDC__} is normally 0, but is 1 if the user specifies strict
1036 conformance to the C Standard.  The preprocessor follows the host convention
1037 when processing system include files, but when processing user files it follows
1038 the usual GNU C convention.
1039
1040 This macro is not defined if the @samp{-traditional} option is used.
1041
1042 @item __STDC_VERSION__
1043 @findex __STDC_VERSION__
1044 This macro expands to the C Standard's version number,
1045 a long integer constant of the form @samp{@var{yyyy}@var{mm}L}
1046 where @var{yyyy} and @var{mm} are the year and month of the Standard version.
1047 This signifies which version of the C Standard the preprocessor conforms to.
1048 Like @samp{__STDC__}, whether this version number is accurate
1049 for the entire implementation depends on what C compiler
1050 will operate on the output from the preprocessor.
1051
1052 This macro is not defined if the @samp{-traditional} option is used.
1053
1054 @item __GNUC__
1055 @findex __GNUC__
1056 This macro is defined if and only if this is GNU C@.  This macro is
1057 defined only when the entire GNU C compiler is in use; if you invoke the
1058 preprocessor directly, @samp{__GNUC__} is undefined.  The value
1059 identifies the major version number of GNU CC (@samp{1} for GNU CC
1060 version 1, which is now obsolete, and @samp{2} for version 2).
1061
1062 @item __GNUC_MINOR__
1063 @findex __GNUC_MINOR__
1064 The macro contains the minor version number of the compiler.  This can
1065 be used to work around differences between different releases of the
1066 compiler (for example, if gcc 2.6.3 is known to support a feature, you
1067 can test for @code{__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6)}).
1068
1069 @item __GNUC_PATCHLEVEL__
1070 @findex __GNUC_PATCHLEVEL__
1071 This macro contains the patch level of the compiler.  This can be
1072 used to work around differences between different patch level releases
1073 of the compiler (for example, if gcc 2.6.2 is known to contain a bug,
1074 whereas gcc 2.6.3 contains a fix, and you have code which can workaround
1075 ths problem depending on whether the bug is fixed or not, you can test for
1076 @code{__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 6) || 
1077 (__GNUC__ == 2 && __GNUC_MINOR__ == 6 && __GNUC_PATCHLEVEL__ > 3)}).
1078
1079 @item __GNUG__
1080 @findex __GNUG__
1081 The GNU C compiler defines this when the compilation language is
1082 C++; use @samp{__GNUG__} to distinguish between GNU C and GNU
1083 C++.
1084
1085 @item __cplusplus 
1086 @findex __cplusplus 
1087 The ISO standard for C++ requires predefining this variable.  You can
1088 use @samp{__cplusplus} to test whether a header is compiled by a C
1089 compiler or a C++ compiler. The compiler currently uses a value of
1090 @samp{1}, instead of the value @samp{199711L}, which would indicate
1091 full conformance with the standard.
1092
1093 @item __STRICT_ANSI__
1094 @findex __STRICT_ANSI__
1095 GNU C defines this macro if and only if the @samp{-ansi} switch was
1096 specified when GNU C was invoked.  Its definition is the null string.
1097 This macro exists primarily to direct certain GNU header files not to
1098 define certain traditional Unix constructs which are incompatible with
1099 ANSI C@.
1100
1101 @item __BASE_FILE__
1102 @findex __BASE_FILE__
1103 This macro expands to the name of the main input file, in the form
1104 of a C string constant.  This is the source file that was specified
1105 as an argument when the C compiler was invoked.
1106
1107 @item __INCLUDE_LEVEL__
1108 @findex __INCLUDE_LEVEL_
1109 This macro expands to a decimal integer constant that represents the
1110 depth of nesting in include files.  The value of this macro is
1111 incremented on every @samp{#include} directive and decremented at every
1112 end of file.  For input files specified by command line arguments,
1113 the nesting level is zero.
1114
1115 @item __VERSION__
1116 @findex __VERSION__
1117 This macro expands to a string constant which describes the version number of
1118 GNU C@.  The string is normally a sequence of decimal numbers separated
1119 by periods, such as @samp{"2.6.0"}.
1120
1121 @item __OPTIMIZE__
1122 @findex __OPTIMIZE__
1123 GNU CC defines this macro in optimizing compilations.  It causes certain
1124 GNU header files to define alternative macro definitions for some system
1125 library functions.  You should not refer to or test the definition of
1126 this macro unless you make very sure that programs will execute with the
1127 same effect regardless.
1128
1129 @item __CHAR_UNSIGNED__
1130 @findex __CHAR_UNSIGNED__
1131 GNU C defines this macro if and only if the data type @code{char} is
1132 unsigned on the target machine.  It exists to cause the standard header
1133 file @file{limits.h} to work correctly.  You should not refer to this
1134 macro yourself; instead, refer to the standard macros defined in
1135 @file{limits.h}.  The preprocessor uses this macro to determine whether
1136 or not to sign-extend large character constants written in octal; see
1137 @ref{#if Directive,,The @samp{#if} Directive}.
1138
1139 @item __REGISTER_PREFIX__
1140 @findex __REGISTER_PREFIX__
1141 This macro expands to a string (not a string constant) describing the
1142 prefix applied to CPU registers in assembler code.  You can use it to
1143 write assembler code that is usable in multiple environments.  For
1144 example, in the @samp{m68k-aout} environment it expands to the null
1145 string, but in the @samp{m68k-coff} environment it expands to the string
1146 @samp{%}.
1147
1148 @item __USER_LABEL_PREFIX__
1149 @findex __USER_LABEL_PREFIX__
1150 Similar to @code{__REGISTER_PREFIX__}, but describes the prefix applied
1151 to user generated labels in assembler code.  For example, in the
1152 @samp{m68k-aout} environment it expands to the string @samp{_}, but in
1153 the @samp{m68k-coff} environment it expands to the null string.  This
1154 does not work with the @samp{-mno-underscores} option that the i386
1155 OSF/rose and m88k targets provide nor with the @samp{-mcall*} options of
1156 the rs6000 System V Release 4 target.
1157 @end table
1158
1159 @node Nonstandard Predefined,, Standard Predefined, Predefined
1160 @subsubsection Nonstandard Predefined Macros
1161
1162 The C preprocessor normally has several predefined macros that vary between
1163 machines because their purpose is to indicate what type of system and
1164 machine is in use.  This manual, being for all systems and machines, cannot
1165 tell you exactly what their names are; instead, we offer a list of some
1166 typical ones.  You can use @samp{cpp -dM} to see the values of
1167 predefined macros; see @ref{Invocation}.
1168
1169 Some nonstandard predefined macros describe the operating system in use,
1170 with more or less specificity.  For example,
1171
1172 @table @code
1173 @item unix
1174 @findex unix
1175 @samp{unix} is normally predefined on all Unix systems.
1176
1177 @item BSD
1178 @findex BSD
1179 @samp{BSD} is predefined on recent versions of Berkeley Unix
1180 (perhaps only in version 4.3).
1181 @end table
1182
1183 Other nonstandard predefined macros describe the kind of CPU, with more or
1184 less specificity.  For example,
1185
1186 @table @code
1187 @item vax
1188 @findex vax
1189 @samp{vax} is predefined on Vax computers.
1190
1191 @item mc68000
1192 @findex mc68000
1193 @samp{mc68000} is predefined on most computers whose CPU is a Motorola
1194 68000, 68010 or 68020.
1195
1196 @item m68k
1197 @findex m68k
1198 @samp{m68k} is also predefined on most computers whose CPU is a 68000,
1199 68010 or 68020; however, some makers use @samp{mc68000} and some use
1200 @samp{m68k}.  Some predefine both names.  What happens in GNU C
1201 depends on the system you are using it on.
1202
1203 @item M68020
1204 @findex M68020
1205 @samp{M68020} has been observed to be predefined on some systems that
1206 use 68020 CPUs---in addition to @samp{mc68000} and @samp{m68k}, which
1207 are less specific.
1208
1209 @item _AM29K
1210 @findex _AM29K
1211 @itemx _AM29000
1212 @findex _AM29000
1213 Both @samp{_AM29K} and @samp{_AM29000} are predefined for the AMD 29000
1214 CPU family.
1215
1216 @item ns32000
1217 @findex ns32000
1218 @samp{ns32000} is predefined on computers which use the National
1219 Semiconductor 32000 series CPU.
1220 @end table
1221
1222 Yet other nonstandard predefined macros describe the manufacturer of
1223 the system.  For example,
1224
1225 @table @code
1226 @item sun
1227 @findex sun
1228 @samp{sun} is predefined on all models of Sun computers.
1229
1230 @item pyr
1231 @findex pyr
1232 @samp{pyr} is predefined on all models of Pyramid computers.
1233
1234 @item sequent
1235 @findex sequent
1236 @samp{sequent} is predefined on all models of Sequent computers.
1237 @end table
1238
1239 These predefined symbols are not only nonstandard, they are contrary to the
1240 ANSI standard because their names do not start with underscores.
1241 Therefore, the option @samp{-ansi} inhibits the definition of these
1242 symbols.
1243
1244 This tends to make @samp{-ansi} useless, since many programs depend on the
1245 customary nonstandard predefined symbols.  Even system header files check
1246 them and will generate incorrect declarations if they do not find the names
1247 that are expected.  You might think that the header files supplied for the
1248 Uglix computer would not need to test what machine they are running on,
1249 because they can simply assume it is the Uglix; but often they do, and they
1250 do so using the customary names.  As a result, very few C programs will
1251 compile with @samp{-ansi}.  We intend to avoid such problems on the GNU
1252 system.
1253
1254 What, then, should you do in an ANSI C program to test the type of machine
1255 it will run on?
1256
1257 GNU C offers a parallel series of symbols for this purpose, whose names
1258 are made from the customary ones by adding @samp{__} at the beginning
1259 and end.  Thus, the symbol @code{__vax__} would be available on a Vax,
1260 and so on.
1261
1262 The set of nonstandard predefined names in the GNU C preprocessor is
1263 controlled (when @code{cpp} is itself compiled) by the macro
1264 @samp{CPP_PREDEFINES}, which should be a string containing @samp{-D}
1265 options, separated by spaces.  For example, on the Sun 3, we use the
1266 following definition:
1267
1268 @example
1269 #define CPP_PREDEFINES "-Dmc68000 -Dsun -Dunix -Dm68k"
1270 @end example
1271
1272 @noindent 
1273 This macro is usually specified in @file{tm.h}.
1274
1275 @node Stringification, Concatenation, Predefined, Macros
1276 @subsection Stringification
1277
1278 @cindex stringification
1279 @dfn{Stringification} means turning a code fragment into a string constant
1280 whose contents are the text for the code fragment.  For example,
1281 stringifying @samp{foo (z)} results in @samp{"foo (z)"}.
1282
1283 In the C preprocessor, stringification is an option available when macro
1284 arguments are substituted into the macro definition.  In the body of the
1285 definition, when an argument name appears, the character @samp{#} before
1286 the name specifies stringification of the corresponding actual argument
1287 when it is substituted at that point in the definition.  The same argument
1288 may be substituted in other places in the definition without
1289 stringification if the argument name appears in those places with no
1290 @samp{#}.
1291
1292 Here is an example of a macro definition that uses stringification:
1293
1294 @smallexample
1295 @group
1296 #define WARN_IF(EXP) \
1297 do @{ if (EXP) \
1298         fprintf (stderr, "Warning: " #EXP "\n"); @} \
1299 while (0)
1300 @end group
1301 @end smallexample
1302
1303 @noindent
1304 Here the actual argument for @samp{EXP} is substituted once as given,
1305 into the @samp{if} statement, and once as stringified, into the
1306 argument to @samp{fprintf}.  The @samp{do} and @samp{while (0)} are
1307 a kludge to make it possible to write @samp{WARN_IF (@var{arg});},
1308 which the resemblance of @samp{WARN_IF} to a function would make
1309 C programmers want to do; see @ref{Swallow Semicolon}.
1310
1311 The stringification feature is limited to transforming one macro argument
1312 into one string constant: there is no way to combine the argument with
1313 other text and then stringify it all together.  But the example above shows
1314 how an equivalent result can be obtained in ANSI Standard C using the
1315 feature that adjacent string constants are concatenated as one string
1316 constant.  The preprocessor stringifies the actual value of @samp{EXP} 
1317 into a separate string constant, resulting in text like
1318
1319 @smallexample
1320 @group
1321 do @{ if (x == 0) \
1322         fprintf (stderr, "Warning: " "x == 0" "\n"); @} \
1323 while (0)
1324 @end group
1325 @end smallexample
1326
1327 @noindent
1328 but the C compiler then sees three consecutive string constants and
1329 concatenates them into one, producing effectively
1330
1331 @smallexample
1332 do @{ if (x == 0) \
1333         fprintf (stderr, "Warning: x == 0\n"); @} \
1334 while (0)
1335 @end smallexample
1336
1337 Stringification in C involves more than putting doublequote characters
1338 around the fragment; it is necessary to put backslashes in front of all
1339 doublequote characters, and all backslashes in string and character
1340 constants, in order to get a valid C string constant with the proper
1341 contents.  Thus, stringifying @samp{p = "foo\n";} results in @samp{"p =
1342 \"foo\\n\";"}.  However, backslashes that are not inside of string or
1343 character constants are not duplicated: @samp{\n} by itself stringifies to
1344 @samp{"\n"}.
1345
1346 Whitespace (including comments) in the text being stringified is handled
1347 according to precise rules.  All leading and trailing whitespace is ignored.
1348 Any sequence of whitespace in the middle of the text is converted to
1349 a single space in the stringified result.
1350
1351 @node Concatenation, Undefining, Stringification, Macros
1352 @subsection Concatenation
1353 @cindex concatenation
1354 @cindex @samp{##}
1355 @dfn{Concatenation} means joining two strings into one.  In the context
1356 of macro expansion, concatenation refers to joining two lexical units
1357 into one longer one.  Specifically, an actual argument to the macro can be
1358 concatenated with another actual argument or with fixed text to produce
1359 a longer name.  The longer name might be the name of a function,
1360 variable or type, or a C keyword; it might even be the name of another
1361 macro, in which case it will be expanded.
1362
1363 When you define a macro, you request concatenation with the special
1364 operator @samp{##} in the macro body.  When the macro is called,
1365 after actual arguments are substituted, all @samp{##} operators are
1366 deleted, and so is any whitespace next to them (including whitespace
1367 that was part of an actual argument).  The result is to concatenate
1368 the syntactic tokens on either side of the @samp{##}.
1369
1370 Consider a C program that interprets named commands.  There probably needs
1371 to be a table of commands, perhaps an array of structures declared as
1372 follows:
1373
1374 @example
1375 struct command
1376 @{
1377   char *name;
1378   void (*function) ();
1379 @};
1380
1381 struct command commands[] =
1382 @{
1383   @{ "quit", quit_command@},
1384   @{ "help", help_command@},
1385   @dots{}
1386 @};
1387 @end example
1388
1389 It would be cleaner not to have to give each command name twice, once in
1390 the string constant and once in the function name.  A macro which takes the
1391 name of a command as an argument can make this unnecessary.  The string
1392 constant can be created with stringification, and the function name by
1393 concatenating the argument with @samp{_command}.  Here is how it is done:
1394
1395 @example
1396 #define COMMAND(NAME)  @{ #NAME, NAME ## _command @}
1397
1398 struct command commands[] =
1399 @{
1400   COMMAND (quit),
1401   COMMAND (help),
1402   @dots{}
1403 @};
1404 @end example
1405
1406 The usual case of concatenation is concatenating two names (or a name and a
1407 number) into a longer name.  But this isn't the only valid case.  It is
1408 also possible to concatenate two numbers (or a number and a name, such as
1409 @samp{1.5} and @samp{e3}) into a number.  Also, multi-character operators
1410 such as @samp{+=} can be formed by concatenation.  In some cases it is even
1411 possible to piece together a string constant.  However, two pieces of text
1412 that don't together form a valid lexical unit cannot be concatenated.  For
1413 example, concatenation with @samp{x} on one side and @samp{+} on the other
1414 is not meaningful because those two characters can't fit together in any
1415 lexical unit of C@.  The ANSI standard says that such attempts at
1416 concatenation are undefined, but in the GNU C preprocessor it is well
1417 defined: it puts the @samp{x} and @samp{+} side by side with no particular
1418 special results.
1419
1420 Keep in mind that the C preprocessor converts comments to whitespace before
1421 macros are even considered.  Therefore, you cannot create a comment by
1422 concatenating @samp{/} and @samp{*}: the @samp{/*} sequence that starts a
1423 comment is not a lexical unit, but rather the beginning of a ``long'' space
1424 character.  Also, you can freely use comments next to a @samp{##} in a
1425 macro definition, or in actual arguments that will be concatenated, because
1426 the comments will be converted to spaces at first sight, and concatenation
1427 will later discard the spaces.
1428
1429 @node Undefining, Redefining, Concatenation, Macros
1430 @subsection Undefining Macros
1431
1432 @cindex undefining macros
1433 To @dfn{undefine} a macro means to cancel its definition.  This is done
1434 with the @samp{#undef} directive.  @samp{#undef} is followed by the macro
1435 name to be undefined.
1436
1437 Like definition, undefinition occurs at a specific point in the source
1438 file, and it applies starting from that point.  The name ceases to be a
1439 macro name, and from that point on it is treated by the preprocessor as if
1440 it had never been a macro name.
1441
1442 For example,
1443
1444 @example
1445 #define FOO 4
1446 x = FOO;
1447 #undef FOO
1448 x = FOO;
1449 @end example
1450
1451 @noindent
1452 expands into
1453
1454 @example
1455 x = 4;
1456
1457 x = FOO;
1458 @end example
1459
1460 @noindent
1461 In this example, @samp{FOO} had better be a variable or function as well
1462 as (temporarily) a macro, in order for the result of the expansion to be
1463 valid C code.
1464
1465 The same form of @samp{#undef} directive will cancel definitions with
1466 arguments or definitions that don't expect arguments.  The @samp{#undef}
1467 directive has no effect when used on a name not currently defined as a macro.
1468
1469 @node Redefining, Poisoning, Undefining, Macros
1470 @subsection Redefining Macros
1471
1472 @cindex redefining macros
1473 @dfn{Redefining} a macro means defining (with @samp{#define}) a name that
1474 is already defined as a macro.
1475
1476 A redefinition is trivial if the new definition is transparently identical
1477 to the old one.  You probably wouldn't deliberately write a trivial
1478 redefinition, but they can happen automatically when a header file is
1479 included more than once (@pxref{Header Files}), so they are accepted
1480 silently and without effect.
1481
1482 Nontrivial redefinition is considered likely to be an error, so
1483 it provokes a warning message from the preprocessor.  However, sometimes it
1484 is useful to change the definition of a macro in mid-compilation.  You can
1485 inhibit the warning by undefining the macro with @samp{#undef} before the
1486 second definition.
1487
1488 In order for a redefinition to be trivial, the new definition must
1489 exactly match the one already in effect, with two possible exceptions:
1490
1491 @itemize @bullet
1492 @item
1493 Whitespace may be added or deleted at the beginning or the end.
1494
1495 @item
1496 Whitespace may be changed in the middle (but not inside strings).
1497 However, it may not be eliminated entirely, and it may not be added
1498 where there was no whitespace at all.
1499 @end itemize
1500
1501 Recall that a comment counts as whitespace.
1502
1503 @node Poisoning, Macro Pitfalls, Redefining, Macros
1504 @subsection Poisoning Macros
1505 @cindex poisoning macros
1506 @findex #pragma GCC poison
1507 @findex #pragma poison
1508
1509 Sometimes, there is an identifier that you want to remove completely
1510 from your program, and make sure that it never creeps back in.  To
1511 enforce this, the @samp{#pragma GCC poison} directive can be used.
1512 @samp{#pragma GCC poison} is followed by a list of identifiers to poison,
1513 and takes effect for the rest of the source.  You cannot @samp{#undef} a
1514 poisoned identifier or test to see if it's defined with @samp{#ifdef}.
1515
1516 For example,
1517
1518 @example
1519 #pragma GCC poison printf sprintf fprintf
1520 sprintf(some_string, "hello");
1521 @end example
1522
1523 @noindent
1524 will produce an error.
1525
1526 For backwards compatibility @samp{#pragma poison} is also recognized.
1527
1528 @node Macro Pitfalls,, Poisoning, Macros
1529 @subsection Pitfalls and Subtleties of Macros
1530 @cindex problems with macros
1531 @cindex pitfalls of macros
1532
1533 In this section we describe some special rules that apply to macros and
1534 macro expansion, and point out certain cases in which the rules have
1535 counterintuitive consequences that you must watch out for.
1536
1537 @menu
1538 * Misnesting::        Macros can contain unmatched parentheses.
1539 * Macro Parentheses:: Why apparently superfluous parentheses
1540                          may be necessary to avoid incorrect grouping.
1541 * Swallow Semicolon:: Macros that look like functions
1542                          but expand into compound statements.
1543 * Side Effects::      Unsafe macros that cause trouble when
1544                          arguments contain side effects.
1545 * Self-Reference::    Macros whose definitions use the macros' own names.
1546 * Argument Prescan::  Actual arguments are checked for macro calls
1547                          before they are substituted.
1548 * Cascaded Macros::   Macros whose definitions use other macros.
1549 * Newlines in Args::  Sometimes line numbers get confused.
1550 @end menu
1551
1552 @node Misnesting, Macro Parentheses, Macro Pitfalls, Macro Pitfalls
1553 @subsubsection Improperly Nested Constructs
1554
1555 Recall that when a macro is called with arguments, the arguments are
1556 substituted into the macro body and the result is checked, together with
1557 the rest of the input file, for more macro calls.
1558
1559 It is possible to piece together a macro call coming partially from the
1560 macro body and partially from the actual arguments.  For example,
1561
1562 @example
1563 #define double(x) (2*(x))
1564 #define call_with_1(x) x(1)
1565 @end example
1566
1567 @noindent
1568 would expand @samp{call_with_1 (double)} into @samp{(2*(1))}.
1569
1570 Macro definitions do not have to have balanced parentheses.  By writing an
1571 unbalanced open parenthesis in a macro body, it is possible to create a
1572 macro call that begins inside the macro body but ends outside of it.  For
1573 example,
1574
1575 @example
1576 #define strange(file) fprintf (file, "%s %d",
1577 @dots{}
1578 strange(stderr) p, 35)
1579 @end example
1580
1581 @noindent
1582 This bizarre example expands to @samp{fprintf (stderr, "%s %d", p, 35)}!
1583
1584 @node Macro Parentheses, Swallow Semicolon, Misnesting, Macro Pitfalls
1585 @subsubsection Unintended Grouping of Arithmetic
1586 @cindex parentheses in macro bodies
1587
1588 You may have noticed that in most of the macro definition examples shown
1589 above, each occurrence of a macro argument name had parentheses around it.
1590 In addition, another pair of parentheses usually surround the entire macro
1591 definition.  Here is why it is best to write macros that way.
1592
1593 Suppose you define a macro as follows,
1594
1595 @example
1596 #define ceil_div(x, y) (x + y - 1) / y
1597 @end example
1598
1599 @noindent
1600 whose purpose is to divide, rounding up.  (One use for this operation is
1601 to compute how many @samp{int} objects are needed to hold a certain
1602 number of @samp{char} objects.)  Then suppose it is used as follows:
1603
1604 @example
1605 a = ceil_div (b & c, sizeof (int));
1606 @end example
1607
1608 @noindent
1609 This expands into
1610
1611 @example
1612 a = (b & c + sizeof (int) - 1) / sizeof (int);
1613 @end example
1614
1615 @noindent
1616 which does not do what is intended.  The operator-precedence rules of
1617 C make it equivalent to this:
1618
1619 @example
1620 a = (b & (c + sizeof (int) - 1)) / sizeof (int);
1621 @end example
1622
1623 @noindent
1624 But what we want is this:
1625
1626 @example
1627 a = ((b & c) + sizeof (int) - 1)) / sizeof (int);
1628 @end example
1629
1630 @noindent
1631 Defining the macro as
1632
1633 @example
1634 #define ceil_div(x, y) ((x) + (y) - 1) / (y)
1635 @end example
1636
1637 @noindent
1638 provides the desired result.
1639
1640 Unintended grouping can result in another way.  Consider
1641 @samp{sizeof ceil_div(1, 2)}.  That has the appearance of a C expression
1642 that would compute the size of the type of @samp{ceil_div (1, 2)}, but in
1643 fact it means something very different.  Here is what it expands to:
1644
1645 @example
1646 sizeof ((1) + (2) - 1) / (2)
1647 @end example
1648
1649 @noindent
1650 This would take the size of an integer and divide it by two.  The precedence
1651 rules have put the division outside the @samp{sizeof} when it was intended
1652 to be inside.
1653
1654 Parentheses around the entire macro definition can prevent such problems.
1655 Here, then, is the recommended way to define @samp{ceil_div}:
1656
1657 @example
1658 #define ceil_div(x, y) (((x) + (y) - 1) / (y))
1659 @end example
1660
1661 @node Swallow Semicolon, Side Effects, Macro Parentheses, Macro Pitfalls
1662 @subsubsection Swallowing the Semicolon
1663
1664 @cindex semicolons (after macro calls)
1665 Often it is desirable to define a macro that expands into a compound
1666 statement.  Consider, for example, the following macro, that advances a
1667 pointer (the argument @samp{p} says where to find it) across whitespace
1668 characters:
1669
1670 @example
1671 #define SKIP_SPACES(p, limit)  \
1672 @{ register char *lim = (limit); \
1673   while (p != lim) @{            \
1674     if (*p++ != ' ') @{          \
1675       p--; break; @}@}@}
1676 @end example
1677
1678 @noindent
1679 Here Backslash-Newline is used to split the macro definition, which must
1680 be a single line, so that it resembles the way such C code would be
1681 laid out if not part of a macro definition.
1682
1683 A call to this macro might be @samp{SKIP_SPACES (p, lim)}.  Strictly
1684 speaking, the call expands to a compound statement, which is a complete
1685 statement with no need for a semicolon to end it.  But it looks like a
1686 function call.  So it minimizes confusion if you can use it like a function
1687 call, writing a semicolon afterward, as in @samp{SKIP_SPACES (p, lim);}
1688
1689 But this can cause trouble before @samp{else} statements, because the
1690 semicolon is actually a null statement.  Suppose you write
1691
1692 @example
1693 if (*p != 0)
1694   SKIP_SPACES (p, lim);
1695 else @dots{}
1696 @end example
1697
1698 @noindent
1699 The presence of two statements---the compound statement and a null
1700 statement---in between the @samp{if} condition and the @samp{else}
1701 makes invalid C code.
1702
1703 The definition of the macro @samp{SKIP_SPACES} can be altered to solve
1704 this problem, using a @samp{do @dots{} while} statement.  Here is how:
1705
1706 @example
1707 #define SKIP_SPACES(p, limit)     \
1708 do @{ register char *lim = (limit); \
1709      while (p != lim) @{            \
1710        if (*p++ != ' ') @{          \
1711          p--; break; @}@}@}           \
1712 while (0)
1713 @end example
1714
1715 Now @samp{SKIP_SPACES (p, lim);} expands into
1716
1717 @example
1718 do @{@dots{}@} while (0);
1719 @end example
1720
1721 @noindent
1722 which is one statement.
1723
1724 @node Side Effects, Self-Reference, Swallow Semicolon, Macro Pitfalls
1725 @subsubsection Duplication of Side Effects
1726
1727 @cindex side effects (in macro arguments)
1728 @cindex unsafe macros
1729 Many C programs define a macro @samp{min}, for ``minimum'', like this:
1730
1731 @example
1732 #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
1733 @end example
1734
1735 When you use this macro with an argument containing a side effect,
1736 as shown here,
1737
1738 @example
1739 next = min (x + y, foo (z));
1740 @end example
1741
1742 @noindent
1743 it expands as follows:
1744
1745 @example
1746 next = ((x + y) < (foo (z)) ? (x + y) : (foo (z)));
1747 @end example
1748
1749 @noindent
1750 where @samp{x + y} has been substituted for @samp{X} and @samp{foo (z)}
1751 for @samp{Y}.
1752
1753 The function @samp{foo} is used only once in the statement as it appears
1754 in the program, but the expression @samp{foo (z)} has been substituted
1755 twice into the macro expansion.  As a result, @samp{foo} might be called
1756 two times when the statement is executed.  If it has side effects or
1757 if it takes a long time to compute, the results might not be what you
1758 intended.  We say that @samp{min} is an @dfn{unsafe} macro.
1759
1760 The best solution to this problem is to define @samp{min} in a way that
1761 computes the value of @samp{foo (z)} only once.  The C language offers no
1762 standard way to do this, but it can be done with GNU C extensions as
1763 follows:
1764
1765 @example
1766 #define min(X, Y)                     \
1767 (@{ typeof (X) __x = (X), __y = (Y);   \
1768    (__x < __y) ? __x : __y; @})
1769 @end example
1770
1771 If you do not wish to use GNU C extensions, the only solution is to be
1772 careful when @emph{using} the macro @samp{min}.  For example, you can
1773 calculate the value of @samp{foo (z)}, save it in a variable, and use that
1774 variable in @samp{min}:
1775
1776 @example
1777 #define min(X, Y)  ((X) < (Y) ? (X) : (Y))
1778 @dots{}
1779 @{
1780   int tem = foo (z);
1781   next = min (x + y, tem);
1782 @}
1783 @end example
1784
1785 @noindent
1786 (where we assume that @samp{foo} returns type @samp{int}).
1787
1788 @node Self-Reference, Argument Prescan, Side Effects, Macro Pitfalls
1789 @subsubsection Self-Referential Macros
1790
1791 @cindex self-reference
1792 A @dfn{self-referential} macro is one whose name appears in its definition.
1793 A special feature of ANSI Standard C is that the self-reference is not
1794 considered a macro call.  It is passed into the preprocessor output
1795 unchanged.
1796
1797 Let's consider an example:
1798
1799 @example
1800 #define foo (4 + foo)
1801 @end example
1802
1803 @noindent
1804 where @samp{foo} is also a variable in your program.
1805
1806 Following the ordinary rules, each reference to @samp{foo} will expand into
1807 @samp{(4 + foo)}; then this will be rescanned and will expand into @samp{(4
1808 + (4 + foo))}; and so on until it causes a fatal error (memory full) in the
1809 preprocessor.
1810
1811 However, the special rule about self-reference cuts this process short
1812 after one step, at @samp{(4 + foo)}.  Therefore, this macro definition
1813 has the possibly useful effect of causing the program to add 4 to
1814 the value of @samp{foo} wherever @samp{foo} is referred to.
1815
1816 In most cases, it is a bad idea to take advantage of this feature.  A
1817 person reading the program who sees that @samp{foo} is a variable will
1818 not expect that it is a macro as well.  The reader will come across the
1819 identifier @samp{foo} in the program and think its value should be that
1820 of the variable @samp{foo}, whereas in fact the value is four greater.
1821
1822 The special rule for self-reference applies also to @dfn{indirect}
1823 self-reference.  This is the case where a macro @var{x} expands to use a
1824 macro @samp{y}, and the expansion of @samp{y} refers to the macro
1825 @samp{x}.  The resulting reference to @samp{x} comes indirectly from the
1826 expansion of @samp{x}, so it is a self-reference and is not further
1827 expanded.  Thus, after
1828
1829 @example
1830 #define x (4 + y)
1831 #define y (2 * x)
1832 @end example
1833
1834 @noindent
1835 @samp{x} would expand into @samp{(4 + (2 * x))}.  Clear?
1836
1837 But suppose @samp{y} is used elsewhere, not from the definition of @samp{x}.
1838 Then the use of @samp{x} in the expansion of @samp{y} is not a self-reference
1839 because @samp{x} is not ``in progress''.  So it does expand.  However,
1840 the expansion of @samp{x} contains a reference to @samp{y}, and that
1841 is an indirect self-reference now because @samp{y} is ``in progress''.
1842 The result is that @samp{y} expands to @samp{(2 * (4 + y))}.
1843
1844 It is not clear that this behavior would ever be useful, but it is specified
1845 by the ANSI C standard, so you may need to understand it.
1846
1847 @node Argument Prescan, Cascaded Macros, Self-Reference, Macro Pitfalls
1848 @subsubsection Separate Expansion of Macro Arguments
1849 @cindex expansion of arguments
1850 @cindex macro argument expansion
1851 @cindex prescan of macro arguments
1852
1853 We have explained that the expansion of a macro, including the substituted
1854 actual arguments, is scanned over again for macro calls to be expanded.
1855
1856 What really happens is more subtle: first each actual argument text is scanned
1857 separately for macro calls.  Then the results of this are substituted into
1858 the macro body to produce the macro expansion, and the macro expansion
1859 is scanned again for macros to expand.
1860
1861 The result is that the actual arguments are scanned @emph{twice} to expand
1862 macro calls in them.
1863
1864 Most of the time, this has no effect.  If the actual argument contained
1865 any macro calls, they are expanded during the first scan.  The result
1866 therefore contains no macro calls, so the second scan does not change it.
1867 If the actual argument were substituted as given, with no prescan,
1868 the single remaining scan would find the same macro calls and produce
1869 the same results.
1870
1871 You might expect the double scan to change the results when a
1872 self-referential macro is used in an actual argument of another macro
1873 (@pxref{Self-Reference}): the self-referential macro would be expanded once
1874 in the first scan, and a second time in the second scan.  But this is not
1875 what happens.  The self-references that do not expand in the first scan are
1876 marked so that they will not expand in the second scan either.
1877
1878 The prescan is not done when an argument is stringified or concatenated.
1879 Thus,
1880
1881 @example
1882 #define str(s) #s
1883 #define foo 4
1884 str (foo)
1885 @end example
1886
1887 @noindent
1888 expands to @samp{"foo"}.  Once more, prescan has been prevented from
1889 having any noticeable effect.
1890
1891 More precisely, stringification and concatenation use the argument as
1892 written, in un-prescanned form.  The same actual argument would be used in
1893 prescanned form if it is substituted elsewhere without stringification or
1894 concatenation.
1895
1896 @example
1897 #define str(s) #s lose(s)
1898 #define foo 4
1899 str (foo)
1900 @end example
1901
1902 expands to @samp{"foo" lose(4)}.
1903
1904 You might now ask, ``Why mention the prescan, if it makes no difference?
1905 And why not skip it and make the preprocessor faster?''  The answer is
1906 that the prescan does make a difference in three special cases:
1907
1908 @itemize @bullet
1909 @item
1910 Nested calls to a macro.
1911
1912 @item
1913 Macros that call other macros that stringify or concatenate.
1914
1915 @item
1916 Macros whose expansions contain unshielded commas.
1917 @end itemize
1918
1919 We say that @dfn{nested} calls to a macro occur when a macro's actual
1920 argument contains a call to that very macro.  For example, if @samp{f}
1921 is a macro that expects one argument, @samp{f (f (1))} is a nested
1922 pair of calls to @samp{f}.  The desired expansion is made by
1923 expanding @samp{f (1)} and substituting that into the definition of
1924 @samp{f}.  The prescan causes the expected result to happen.
1925 Without the prescan, @samp{f (1)} itself would be substituted as
1926 an actual argument, and the inner use of @samp{f} would appear
1927 during the main scan as an indirect self-reference and would not
1928 be expanded.  Here, the prescan cancels an undesirable side effect
1929 (in the medical, not computational, sense of the term) of the special
1930 rule for self-referential macros.
1931
1932 But prescan causes trouble in certain other cases of nested macro calls.
1933 Here is an example:
1934
1935 @example
1936 #define foo  a,b
1937 #define bar(x) lose(x)
1938 #define lose(x) (1 + (x))
1939
1940 bar(foo)
1941 @end example
1942
1943 @noindent
1944 We would like @samp{bar(foo)} to turn into @samp{(1 + (foo))}, which
1945 would then turn into @samp{(1 + (a,b))}.  But instead, @samp{bar(foo)}
1946 expands into @samp{lose(a,b)}, and you get an error because @code{lose}
1947 requires a single argument.  In this case, the problem is easily solved
1948 by the same parentheses that ought to be used to prevent misnesting of
1949 arithmetic operations:
1950
1951 @example
1952 #define foo (a,b)
1953 #define bar(x) lose((x))
1954 @end example
1955
1956 The problem is more serious when the operands of the macro are not
1957 expressions; for example, when they are statements.  Then parentheses
1958 are unacceptable because they would make for invalid C code:
1959
1960 @example
1961 #define foo @{ int a, b; @dots{} @}
1962 @end example
1963
1964 @noindent
1965 In GNU C you can shield the commas using the @samp{(@{@dots{}@})}
1966 construct which turns a compound statement into an expression:
1967
1968 @example
1969 #define foo (@{ int a, b; @dots{} @})
1970 @end example
1971
1972 Or you can rewrite the macro definition to avoid such commas:
1973
1974 @example
1975 #define foo @{ int a; int b; @dots{} @}
1976 @end example
1977
1978 There is also one case where prescan is useful.  It is possible
1979 to use prescan to expand an argument and then stringify it---if you use
1980 two levels of macros.  Let's add a new macro @samp{xstr} to the
1981 example shown above:
1982
1983 @example
1984 #define xstr(s) str(s)
1985 #define str(s) #s
1986 #define foo 4
1987 xstr (foo)
1988 @end example
1989
1990 This expands into @samp{"4"}, not @samp{"foo"}.  The reason for the
1991 difference is that the argument of @samp{xstr} is expanded at prescan
1992 (because @samp{xstr} does not specify stringification or concatenation of
1993 the argument).  The result of prescan then forms the actual argument for
1994 @samp{str}.  @samp{str} uses its argument without prescan because it
1995 performs stringification; but it cannot prevent or undo the prescanning
1996 already done by @samp{xstr}.
1997
1998 @node Cascaded Macros, Newlines in Args, Argument Prescan, Macro Pitfalls
1999 @subsubsection Cascaded Use of Macros
2000
2001 @cindex cascaded macros
2002 @cindex macro body uses macro
2003 A @dfn{cascade} of macros is when one macro's body contains a reference
2004 to another macro.  This is very common practice.  For example,
2005
2006 @example
2007 #define BUFSIZE 1020
2008 #define TABLESIZE BUFSIZE
2009 @end example
2010
2011 This is not at all the same as defining @samp{TABLESIZE} to be @samp{1020}.
2012 The @samp{#define} for @samp{TABLESIZE} uses exactly the body you
2013 specify---in this case, @samp{BUFSIZE}---and does not check to see whether
2014 it too is the name of a macro.
2015
2016 It's only when you @emph{use} @samp{TABLESIZE} that the result of its expansion
2017 is checked for more macro names.
2018
2019 This makes a difference if you change the definition of @samp{BUFSIZE}
2020 at some point in the source file.  @samp{TABLESIZE}, defined as shown,
2021 will always expand using the definition of @samp{BUFSIZE} that is
2022 currently in effect:
2023
2024 @example
2025 #define BUFSIZE 1020
2026 #define TABLESIZE BUFSIZE
2027 #undef BUFSIZE
2028 #define BUFSIZE 37
2029 @end example
2030
2031 @noindent
2032 Now @samp{TABLESIZE} expands (in two stages) to @samp{37}.  (The
2033 @samp{#undef} is to prevent any warning about the nontrivial
2034 redefinition of @code{BUFSIZE}.)
2035
2036 @node Newlines in Args,, Cascaded Macros, Macro Pitfalls
2037 @subsection Newlines in Macro Arguments
2038 @cindex newlines in macro arguments
2039
2040 Traditional macro processing carries forward all newlines in macro
2041 arguments into the expansion of the macro.  This means that, if some of
2042 the arguments are substituted more than once, or not at all, or out of
2043 order, newlines can be duplicated, lost, or moved around within the
2044 expansion.  If the expansion consists of multiple statements, then the
2045 effect is to distort the line numbers of some of these statements.  The
2046 result can be incorrect line numbers, in error messages or displayed in
2047 a debugger.
2048
2049 The GNU C preprocessor operating in ANSI C mode adjusts appropriately
2050 for multiple use of an argument---the first use expands all the
2051 newlines, and subsequent uses of the same argument produce no newlines.
2052 But even in this mode, it can produce incorrect line numbering if
2053 arguments are used out of order, or not used at all.
2054
2055 Here is an example illustrating this problem:
2056
2057 @example
2058 #define ignore_second_arg(a,b,c) a; c
2059
2060 ignore_second_arg (foo (),
2061                    ignored (),
2062                    syntax error);
2063 @end example
2064
2065 @noindent
2066 The syntax error triggered by the tokens @samp{syntax error} results
2067 in an error message citing line four, even though the statement text
2068 comes from line five.
2069
2070 @node Conditionals, Combining Sources, Macros, Top
2071 @section Conditionals
2072
2073 @cindex conditionals
2074 In a macro processor, a @dfn{conditional} is a directive that allows a part
2075 of the program to be ignored during compilation, on some conditions.
2076 In the C preprocessor, a conditional can test either an arithmetic expression
2077 or whether a name is defined as a macro.
2078
2079 A conditional in the C preprocessor resembles in some ways an @samp{if}
2080 statement in C, but it is important to understand the difference between
2081 them.  The condition in an @samp{if} statement is tested during the execution
2082 of your program.  Its purpose is to allow your program to behave differently
2083 from run to run, depending on the data it is operating on.  The condition
2084 in a preprocessing conditional directive is tested when your program is compiled.
2085 Its purpose is to allow different code to be included in the program depending
2086 on the situation at the time of compilation.
2087
2088 @menu
2089 * Uses: Conditional Uses.       What conditionals are for.
2090 * Syntax: Conditional Syntax.   How conditionals are written.
2091 * Deletion: Deleted Code.       Making code into a comment.
2092 * Macros: Conditionals-Macros.  Why conditionals are used with macros.
2093 * Assertions::                  How and why to use assertions.
2094 * Errors: #error Directive.     Detecting inconsistent compilation parameters.
2095 @end menu
2096
2097 @node Conditional Uses
2098 @subsection Why Conditionals are Used
2099
2100 Generally there are three kinds of reason to use a conditional.
2101
2102 @itemize @bullet
2103 @item
2104 A program may need to use different code depending on the machine or
2105 operating system it is to run on.  In some cases the code for one
2106 operating system may be erroneous on another operating system; for
2107 example, it might refer to library routines that do not exist on the
2108 other system.  When this happens, it is not enough to avoid executing
2109 the invalid code: merely having it in the program makes it impossible
2110 to link the program and run it.  With a preprocessing conditional, the
2111 offending code can be effectively excised from the program when it is
2112 not valid.
2113
2114 @item
2115 You may want to be able to compile the same source file into two
2116 different programs.  Sometimes the difference between the programs is
2117 that one makes frequent time-consuming consistency checks on its
2118 intermediate data, or prints the values of those data for debugging,
2119 while the other does not.
2120
2121 @item
2122 A conditional whose condition is always false is a good way to exclude
2123 code from the program but keep it as a sort of comment for future
2124 reference.
2125 @end itemize
2126
2127 Most simple programs that are intended to run on only one machine will
2128 not need to use preprocessing conditionals.
2129
2130 @node Conditional Syntax
2131 @subsection Syntax of Conditionals
2132
2133 @findex #if
2134 A conditional in the C preprocessor begins with a @dfn{conditional
2135 directive}: @samp{#if}, @samp{#ifdef} or @samp{#ifndef}.
2136 @xref{Conditionals-Macros}, for information on @samp{#ifdef} and
2137 @samp{#ifndef}; only @samp{#if} is explained here.
2138
2139 @menu
2140 * If: #if Directive.     Basic conditionals using @samp{#if} and @samp{#endif}.
2141 * Else: #else Directive. Including some text if the condition fails.
2142 * Elif: #elif Directive. Testing several alternative possibilities.
2143 @end menu
2144
2145 @node #if Directive
2146 @subsubsection The @samp{#if} Directive
2147
2148 The @samp{#if} directive in its simplest form consists of
2149
2150 @example
2151 #if @var{expression}
2152 @var{controlled text}
2153 #endif /* @var{expression} */
2154 @end example
2155
2156 The comment following the @samp{#endif} is not required, but it is a good
2157 practice because it helps people match the @samp{#endif} to the
2158 corresponding @samp{#if}.  Such comments should always be used, except in
2159 short conditionals that are not nested.  In fact, you can put anything at
2160 all after the @samp{#endif} and it will be ignored by the GNU C preprocessor,
2161 but only comments are acceptable in ANSI Standard C@.
2162
2163 @var{expression} is a C expression of integer type, subject to stringent
2164 restrictions.  It may contain
2165
2166 @itemize @bullet
2167 @item
2168 Integer constants, which are all regarded as @code{long} or
2169 @code{unsigned long}.
2170
2171 @item
2172 Character constants, which are interpreted according to the character
2173 set and conventions of the machine and operating system on which the
2174 preprocessor is running.  The GNU C preprocessor uses the C data type
2175 @samp{char} for these character constants; therefore, whether some
2176 character codes are negative is determined by the C compiler used to
2177 compile the preprocessor.  If it treats @samp{char} as signed, then
2178 character codes large enough to set the sign bit will be considered
2179 negative; otherwise, no character code is considered negative.
2180
2181 @item
2182 Arithmetic operators for addition, subtraction, multiplication,
2183 division, bitwise operations, shifts, comparisons, and logical
2184 operations (@samp{&&} and @samp{||}).
2185
2186 @item
2187 Identifiers that are not macros, which are all treated as zero(!).
2188
2189 @item
2190 Macro calls.  All macro calls in the expression are expanded before
2191 actual computation of the expression's value begins.
2192 @end itemize
2193
2194 Note that @samp{sizeof} operators and @code{enum}-type values are not allowed.
2195 @code{enum}-type values, like all other identifiers that are not taken
2196 as macro calls and expanded, are treated as zero.
2197
2198 The @var{controlled text} inside of a conditional can include
2199 preprocessing directives.  Then the directives inside the conditional are
2200 obeyed only if that branch of the conditional succeeds.  The text can
2201 also contain other conditional groups.  However, the @samp{#if} and
2202 @samp{#endif} directives must balance.
2203
2204 @node #else Directive
2205 @subsubsection The @samp{#else} Directive
2206
2207 @findex #else
2208 The @samp{#else} directive can be added to a conditional to provide
2209 alternative text to be used if the condition is false.  This is what
2210 it looks like:
2211
2212 @example
2213 #if @var{expression}
2214 @var{text-if-true}
2215 #else /* Not @var{expression} */
2216 @var{text-if-false}
2217 #endif /* Not @var{expression} */
2218 @end example
2219
2220 If @var{expression} is nonzero, and thus the @var{text-if-true} is 
2221 active, then @samp{#else} acts like a failing conditional and the
2222 @var{text-if-false} is ignored.  Contrariwise, if the @samp{#if}
2223 conditional fails, the @var{text-if-false} is considered included.
2224
2225 @node #elif Directive
2226 @subsubsection The @samp{#elif} Directive
2227
2228 @findex #elif
2229 One common case of nested conditionals is used to check for more than two
2230 possible alternatives.  For example, you might have
2231
2232 @example
2233 #if X == 1
2234 @dots{}
2235 #else /* X != 1 */
2236 #if X == 2
2237 @dots{}
2238 #else /* X != 2 */
2239 @dots{}
2240 #endif /* X != 2 */
2241 #endif /* X != 1 */
2242 @end example
2243
2244 Another conditional directive, @samp{#elif}, allows this to be abbreviated
2245 as follows:
2246
2247 @example
2248 #if X == 1
2249 @dots{}
2250 #elif X == 2
2251 @dots{}
2252 #else /* X != 2 and X != 1*/
2253 @dots{}
2254 #endif /* X != 2 and X != 1*/
2255 @end example
2256
2257 @samp{#elif} stands for ``else if''.  Like @samp{#else}, it goes in the
2258 middle of a @samp{#if}-@samp{#endif} pair and subdivides it; it does not
2259 require a matching @samp{#endif} of its own.  Like @samp{#if}, the
2260 @samp{#elif} directive includes an expression to be tested.
2261
2262 The text following the @samp{#elif} is processed only if the original
2263 @samp{#if}-condition failed and the @samp{#elif} condition succeeds.
2264 More than one @samp{#elif} can go in the same @samp{#if}-@samp{#endif}
2265 group.  Then the text after each @samp{#elif} is processed only if the
2266 @samp{#elif} condition succeeds after the original @samp{#if} and any
2267 previous @samp{#elif} directives within it have failed.  @samp{#else} is
2268 equivalent to @samp{#elif 1}, and @samp{#else} is allowed after any
2269 number of @samp{#elif} directives, but @samp{#elif} may not follow
2270 @samp{#else}.
2271
2272 @node Deleted Code
2273 @subsection Keeping Deleted Code for Future Reference
2274 @cindex commenting out code
2275
2276 If you replace or delete a part of the program but want to keep the old
2277 code around as a comment for future reference, the easy way to do this
2278 is to put @samp{#if 0} before it and @samp{#endif} after it.  This is
2279 better than using comment delimiters @samp{/*} and @samp{*/} since those
2280 won't work if the code already contains comments (C comments do not
2281 nest).
2282
2283 This works even if the code being turned off contains conditionals, but
2284 they must be entire conditionals (balanced @samp{#if} and @samp{#endif}).
2285
2286 Conversely, do not use @samp{#if 0} for comments which are not C code.
2287 Use the comment delimiters @samp{/*} and @samp{*/} instead.  The
2288 interior of @samp{#if 0} must consist of complete tokens; in particular,
2289 singlequote characters must balance.  But comments often contain
2290 unbalanced singlequote characters (known in English as apostrophes).
2291 These confuse @samp{#if 0}.  They do not confuse @samp{/*}.
2292
2293 @node Conditionals-Macros
2294 @subsection Conditionals and Macros
2295
2296 Conditionals are useful in connection with macros or assertions, because
2297 those are the only ways that an expression's value can vary from one
2298 compilation to another.  A @samp{#if} directive whose expression uses no
2299 macros or assertions is equivalent to @samp{#if 1} or @samp{#if 0}; you
2300 might as well determine which one, by computing the value of the
2301 expression yourself, and then simplify the program.
2302
2303 For example, here is a conditional that tests the expression
2304 @samp{BUFSIZE == 1020}, where @samp{BUFSIZE} must be a macro.
2305
2306 @example
2307 #if BUFSIZE == 1020
2308   printf ("Large buffers!\n");
2309 #endif /* BUFSIZE is large */
2310 @end example
2311
2312 (Programmers often wish they could test the size of a variable or data
2313 type in @samp{#if}, but this does not work.  The preprocessor does not
2314 understand @code{sizeof}, or typedef names, or even the type keywords
2315 such as @code{int}.)
2316
2317 @findex defined
2318 The special operator @samp{defined} is used in @samp{#if} expressions to
2319 test whether a certain name is defined as a macro.  Either @samp{defined
2320 @var{name}} or @samp{defined (@var{name})} is an expression whose value
2321 is 1 if @var{name} is defined as macro at the current point in the
2322 program, and 0 otherwise.  For the @samp{defined} operator it makes no
2323 difference what the definition of the macro is; all that matters is
2324 whether there is a definition.  Thus, for example,@refill
2325
2326 @example
2327 #if defined (vax) || defined (ns16000)
2328 @end example
2329
2330 @noindent
2331 would succeed if either of the names @samp{vax} and @samp{ns16000} is
2332 defined as a macro.  You can test the same condition using assertions
2333 (@pxref{Assertions}), like this:
2334
2335 @example
2336 #if #cpu (vax) || #cpu (ns16000)
2337 @end example
2338
2339 If a macro is defined and later undefined with @samp{#undef},
2340 subsequent use of the @samp{defined} operator returns 0, because
2341 the name is no longer defined.  If the macro is defined again with
2342 another @samp{#define}, @samp{defined} will recommence returning 1.
2343
2344 @findex #ifdef
2345 @findex #ifndef
2346 Conditionals that test whether just one name is defined are very common,
2347 so there are two special short conditional directives for this case.
2348
2349 @table @code
2350 @item #ifdef @var{name}
2351 is equivalent to @samp{#if defined (@var{name})}.
2352
2353 @item #ifndef @var{name}
2354 is equivalent to @samp{#if ! defined (@var{name})}.
2355 @end table
2356
2357 Macro definitions can vary between compilations for several reasons.
2358
2359 @itemize @bullet
2360 @item
2361 Some macros are predefined on each kind of machine.  For example, on a
2362 Vax, the name @samp{vax} is a predefined macro.  On other machines, it
2363 would not be defined.
2364
2365 @item
2366 Many more macros are defined by system header files.  Different
2367 systems and machines define different macros, or give them different
2368 values.  It is useful to test these macros with conditionals to avoid
2369 using a system feature on a machine where it is not implemented.
2370
2371 @item
2372 Macros are a common way of allowing users to customize a program for
2373 different machines or applications.  For example, the macro
2374 @samp{BUFSIZE} might be defined in a configuration file for your
2375 program that is included as a header file in each source file.  You
2376 would use @samp{BUFSIZE} in a preprocessing conditional in order to
2377 generate different code depending on the chosen configuration.
2378
2379 @item
2380 Macros can be defined or undefined with @samp{-D} and @samp{-U}
2381 command options when you compile the program.  You can arrange to
2382 compile the same source file into two different programs by choosing
2383 a macro name to specify which program you want, writing conditionals
2384 to test whether or how this macro is defined, and then controlling
2385 the state of the macro with compiler command options.
2386 @xref{Invocation}.
2387 @end itemize
2388
2389 @ifinfo
2390 Assertions are usually predefined, but can be defined with preprocessor
2391 directives or command-line options.
2392 @end ifinfo
2393
2394 @node Assertions
2395 @subsection Assertions
2396
2397 @cindex assertions
2398 @dfn{Assertions} are a more systematic alternative to macros in writing
2399 conditionals to test what sort of computer or system the compiled
2400 program will run on.  Assertions are usually predefined, but you can
2401 define them with preprocessing directives or command-line options.
2402
2403 @cindex predicates
2404 The macros traditionally used to describe the type of target are not
2405 classified in any way according to which question they answer; they may
2406 indicate a hardware architecture, a particular hardware model, an
2407 operating system, a particular version of an operating system, or
2408 specific configuration options.  These are jumbled together in a single
2409 namespace.  In contrast, each assertion consists of a named question and
2410 an answer.  The question is usually called the @dfn{predicate}.
2411 An assertion looks like this:
2412
2413 @example
2414 #@var{predicate} (@var{answer})
2415 @end example
2416
2417 @noindent
2418 You must use a properly formed identifier for @var{predicate}.  The
2419 value of @var{answer} can be any sequence of words; all characters are
2420 significant except for leading and trailing whitespace, and differences
2421 in internal whitespace sequences are ignored.  Thus, @samp{x + y} is
2422 different from @samp{x+y} but equivalent to @samp{x + y}.  @samp{)} is
2423 not allowed in an answer.
2424
2425 @cindex testing predicates
2426 Here is a conditional to test whether the answer @var{answer} is asserted
2427 for the predicate @var{predicate}:
2428
2429 @example
2430 #if #@var{predicate} (@var{answer})
2431 @end example
2432
2433 @noindent
2434 There may be more than one answer asserted for a given predicate.  If
2435 you omit the answer, you can test whether @emph{any} answer is asserted
2436 for @var{predicate}:
2437
2438 @example
2439 #if #@var{predicate}
2440 @end example
2441
2442 @findex #system
2443 @findex #machine
2444 @findex #cpu
2445 Most of the time, the assertions you test will be predefined assertions.
2446 GNU C provides three predefined predicates: @code{system}, @code{cpu},
2447 and @code{machine}.  @code{system} is for assertions about the type of
2448 software, @code{cpu} describes the type of computer architecture, and
2449 @code{machine} gives more information about the computer.  For example,
2450 on a GNU system, the following assertions would be true:
2451
2452 @example
2453 #system (gnu)
2454 #system (mach)
2455 #system (mach 3)
2456 #system (mach 3.@var{subversion})
2457 #system (hurd)
2458 #system (hurd @var{version})
2459 @end example
2460
2461 @noindent
2462 and perhaps others.  The alternatives with
2463 more or less version information let you ask more or less detailed
2464 questions about the type of system software.
2465
2466 On a Unix system, you would find @code{#system (unix)} and perhaps one of:
2467 @code{#system (aix)}, @code{#system (bsd)}, @code{#system (hpux)},
2468 @code{#system (lynx)}, @code{#system (mach)}, @code{#system (posix)},
2469 @code{#system (svr3)}, @code{#system (svr4)}, or @code{#system (xpg4)}
2470 with possible version numbers following.
2471
2472 Other values for @code{system} are @code{#system (mvs)}
2473 and @code{#system (vms)}.
2474
2475 @strong{Portability note:} Many Unix C compilers provide only one answer
2476 for the @code{system} assertion: @code{#system (unix)}, if they support
2477 assertions at all.  This is less than useful.
2478
2479 An assertion with a multi-word answer is completely different from several
2480 assertions with individual single-word answers.  For example, the presence
2481 of @code{system (mach 3.0)} does not mean that @code{system (3.0)} is true.
2482 It also does not directly imply @code{system (mach)}, but in GNU C, that
2483 last will normally be asserted as well.
2484
2485 The current list of possible assertion values for @code{cpu} is:
2486 @code{#cpu (a29k)}, @code{#cpu (alpha)}, @code{#cpu (arm)}, @code{#cpu
2487 (clipper)}, @code{#cpu (convex)}, @code{#cpu (elxsi)}, @code{#cpu
2488 (tron)}, @code{#cpu (h8300)}, @code{#cpu (i370)}, @code{#cpu (i386)},
2489 @code{#cpu (i860)}, @code{#cpu (i960)}, @code{#cpu (m68k)}, @code{#cpu
2490 (m88k)}, @code{#cpu (mips)}, @code{#cpu (ns32k)}, @code{#cpu (hppa)},
2491 @code{#cpu (pyr)}, @code{#cpu (ibm032)}, @code{#cpu (rs6000)},
2492 @code{#cpu (sh)}, @code{#cpu (sparc)}, @code{#cpu (spur)}, @code{#cpu
2493 (tahoe)}, @code{#cpu (vax)}, @code{#cpu (we32000)}.
2494
2495 @findex #assert
2496 You can create assertions within a C program using @samp{#assert}, like
2497 this:
2498
2499 @example
2500 #assert @var{predicate} (@var{answer})
2501 @end example
2502
2503 @noindent
2504 (Note the absence of a @samp{#} before @var{predicate}.)
2505
2506 @cindex unassert
2507 @cindex assertions, undoing
2508 @cindex retracting assertions
2509 @findex #unassert
2510 Each time you do this, you assert a new true answer for @var{predicate}.
2511 Asserting one answer does not invalidate previously asserted answers;
2512 they all remain true.  The only way to remove an assertion is with
2513 @samp{#unassert}.  @samp{#unassert} has the same syntax as
2514 @samp{#assert}.  You can also remove all assertions about
2515 @var{predicate} like this:
2516
2517 @example
2518 #unassert @var{predicate}
2519 @end example
2520
2521 You can also add or cancel assertions using command options
2522 when you run @code{gcc} or @code{cpp}.  @xref{Invocation}.
2523
2524 @node #error Directive
2525 @subsection The @samp{#error} and @samp{#warning} Directives
2526
2527 @findex #error
2528 The directive @samp{#error} causes the preprocessor to report a fatal
2529 error.  The rest of the line that follows @samp{#error} is used as the
2530 error message.  The line must consist of complete tokens.
2531
2532 You would use @samp{#error} inside of a conditional that detects a
2533 combination of parameters which you know the program does not properly
2534 support.  For example, if you know that the program will not run
2535 properly on a Vax, you might write
2536
2537 @smallexample
2538 @group
2539 #ifdef __vax__
2540 #error "Won't work on Vaxen.  See comments at get_last_object."
2541 #endif
2542 @end group
2543 @end smallexample
2544
2545 @noindent
2546 @xref{Nonstandard Predefined}, for why this works.
2547
2548 If you have several configuration parameters that must be set up by
2549 the installation in a consistent way, you can use conditionals to detect
2550 an inconsistency and report it with @samp{#error}.  For example,
2551
2552 @smallexample
2553 #if HASH_TABLE_SIZE % 2 == 0 || HASH_TABLE_SIZE % 3 == 0 \
2554     || HASH_TABLE_SIZE % 5 == 0
2555 #error HASH_TABLE_SIZE should not be divisible by a small prime
2556 #endif
2557 @end smallexample
2558
2559 @findex #warning
2560 The directive @samp{#warning} is like the directive @samp{#error}, but causes
2561 the preprocessor to issue a warning and continue preprocessing.  The rest of
2562 the line that follows @samp{#warning} is used as the warning message.
2563
2564 You might use @samp{#warning} in obsolete header files, with a message
2565 directing the user to the header file which should be used instead.
2566
2567 @node Combining Sources, Other Directives, Conditionals, Top
2568 @section Combining Source Files
2569
2570 @cindex line control
2571 One of the jobs of the C preprocessor is to inform the C compiler of where
2572 each line of C code came from: which source file and which line number.
2573
2574 C code can come from multiple source files if you use @samp{#include};
2575 both @samp{#include} and the use of conditionals and macros can cause
2576 the line number of a line in the preprocessor output to be different
2577 from the line's number in the original source file.  You will appreciate
2578 the value of making both the C compiler (in error messages) and symbolic
2579 debuggers such as GDB use the line numbers in your source file.
2580
2581 The C preprocessor builds on this feature by offering a directive by which
2582 you can control the feature explicitly.  This is useful when a file for
2583 input to the C preprocessor is the output from another program such as the
2584 @code{bison} parser generator, which operates on another file that is the
2585 true source file.  Parts of the output from @code{bison} are generated from
2586 scratch, other parts come from a standard parser file.  The rest are copied
2587 nearly verbatim from the source file, but their line numbers in the
2588 @code{bison} output are not the same as their original line numbers.
2589 Naturally you would like compiler error messages and symbolic debuggers to
2590 know the original source file and line number of each line in the
2591 @code{bison} input.
2592
2593 @findex #line
2594 @code{bison} arranges this by writing @samp{#line} directives into the output
2595 file.  @samp{#line} is a directive that specifies the original line number
2596 and source file name for subsequent input in the current preprocessor input
2597 file.  @samp{#line} has three variants:
2598
2599 @table @code
2600 @item #line @var{linenum}
2601 Here @var{linenum} is a decimal integer constant.  This specifies that
2602 the line number of the following line of input, in its original source file,
2603 was @var{linenum}.
2604
2605 @item #line @var{linenum} @var{filename}
2606 Here @var{linenum} is a decimal integer constant and @var{filename}
2607 is a string constant.  This specifies that the following line of input
2608 came originally from source file @var{filename} and its line number there
2609 was @var{linenum}.  Keep in mind that @var{filename} is not just a
2610 file name; it is surrounded by doublequote characters so that it looks
2611 like a string constant.
2612
2613 @item #line @var{anything else}
2614 @var{anything else} is checked for macro calls, which are expanded.
2615 The result should be a decimal integer constant followed optionally
2616 by a string constant, as described above.
2617 @end table
2618
2619 @samp{#line} directives alter the results of the @samp{__FILE__} and
2620 @samp{__LINE__} predefined macros from that point on.  @xref{Standard
2621 Predefined}.
2622
2623 The output of the preprocessor (which is the input for the rest of the
2624 compiler) contains directives that look much like @samp{#line} directives.
2625 They start with just @samp{#} instead of @samp{#line}, but this is
2626 followed by a line number and file name as in @samp{#line}.  @xref{Output}.
2627
2628 @node Other Directives, Output, Combining Sources, Top
2629 @section Miscellaneous Preprocessing Directives
2630
2631 @cindex null directive
2632 This section describes three additional preprocessing directives.  They are
2633 not very useful, but are mentioned for completeness.
2634
2635 The @dfn{null directive} consists of a @samp{#} followed by a Newline, with
2636 only whitespace (including comments) in between.  A null directive is
2637 understood as a preprocessing directive but has no effect on the preprocessor
2638 output.  The primary significance of the existence of the null directive is
2639 that an input line consisting of just a @samp{#} will produce no output,
2640 rather than a line of output containing just a @samp{#}.  Supposedly
2641 some old C programs contain such lines.
2642
2643 @findex #pragma
2644 @findex #pragma GCC
2645
2646 The ANSI standard specifies that the effect of the @samp{#pragma}
2647 directive is implementation-defined.  The GNU C preprocessor recognizes
2648 some pragmas, and passes unrecognized ones through to the preprocessor
2649 output, so they are available to the compilation pass.
2650
2651 In line with the C99 standard, which introduces a STDC namespace for
2652 C99 pragmas, the preprocessor introduces a GCC namespace for GCC
2653 pragmas.  Supported GCC preprocessor pragmas are of the form
2654 @samp{#pragma GCC ...}.  For backwards compatibility previously
2655 supported pragmas are also recognized without the @samp{GCC} prefix,
2656 however that use is deprecated.  Pragmas that are already deprecated
2657 are not recognized with a @samp{GCC} prefix.
2658
2659 @findex #ident
2660 The @samp{#ident} directive is supported for compatibility with certain
2661 other systems.  It is followed by a line of text.  On some systems, the
2662 text is copied into a special place in the object file; on most systems,
2663 the text is ignored and this directive has no effect.  Typically
2664 @samp{#ident} is only used in header files supplied with those systems
2665 where it is meaningful.
2666
2667 @node Output, Invocation, Other Directives, Top
2668 @section C Preprocessor Output
2669
2670 @cindex output format
2671 The output from the C preprocessor looks much like the input, except
2672 that all preprocessing directive lines have been replaced with blank lines
2673 and all comments with spaces.  Whitespace within a line is not altered;
2674 however, unless @samp{-traditional} is used, spaces may be inserted into
2675 the expansions of macro calls to prevent tokens from being concatenated.
2676
2677 Source file name and line number information is conveyed by lines of
2678 the form
2679
2680 @example
2681 # @var{linenum} @var{filename} @var{flags}
2682 @end example
2683
2684 @noindent
2685 which are inserted as needed into the middle of the input (but never
2686 within a string or character constant).  Such a line means that the
2687 following line originated in file @var{filename} at line @var{linenum}.
2688
2689 After the file name comes zero or more flags, which are @samp{1},
2690 @samp{2}, @samp{3}, or @samp{4}.  If there are multiple flags, spaces separate
2691 them.  Here is what the flags mean:
2692
2693 @table @samp
2694 @item 1
2695 This indicates the start of a new file.
2696 @item 2
2697 This indicates returning to a file (after having included another file).
2698 @item 3
2699 This indicates that the following text comes from a system header file,
2700 so certain warnings should be suppressed.
2701 @item 4
2702 This indicates that the following text should be treated as C@.
2703 @c maybe cross reference NO_IMPLICIT_EXTERN_C
2704 @end table
2705
2706 @node Invocation, Concept Index, Output, Top
2707 @section Invoking the C Preprocessor
2708 @cindex invocation of the preprocessor
2709
2710 Most often when you use the C preprocessor you will not have to invoke it
2711 explicitly: the C compiler will do so automatically.  However, the
2712 preprocessor is sometimes useful on its own.
2713
2714 @ignore
2715 @c man begin SYNOPSIS
2716 cpp [@samp{-P}] [@samp{-C}] [@samp{-gcc}] [@samp{-traditional}]
2717     [@samp{-undef}] [@samp{-trigraphs}] [@samp{-pedantic}]
2718     [@samp{-W}@var{warn}...] [@samp{-I}@var{dir}...]
2719     [@samp{-D}@var{macro}[=@var{defn}]...] [@samp{-U}@var{macro}]
2720     [@samp{-A}@var{predicate}(@var{answer})]
2721     [@samp{-M}|@samp{-MM}|@samp{-MD}|@samp{-MMD} [@samp{-MG}]]
2722     [@samp{-x} @var{language}] [@samp{-std=}@var{standard}]
2723     @var{infile} @var{outfile}
2724
2725 Only the most useful options are listed here; see below for the remainder.
2726 @c man end
2727 @c man begin SEEALSO
2728 gcc(1), as(1), ld(1), and the Info entries for @file{cpp}, @file{gcc}, and
2729 @file{binutils}.
2730 @c man end
2731 @end ignore
2732
2733 @c man begin OPTIONS
2734 The C preprocessor expects two file names as arguments, @var{infile} and
2735 @var{outfile}.  The preprocessor reads @var{infile} together with any other
2736 files it specifies with @samp{#include}.  All the output generated by the
2737 combined input files is written in @var{outfile}.
2738
2739 Either @var{infile} or @var{outfile} may be @samp{-}, which as
2740 @var{infile} means to read from standard input and as @var{outfile}
2741 means to write to standard output.  Also, if either file is omitted, it
2742 means the same as if @samp{-} had been specified for that file.
2743
2744 @cindex options
2745 Here is a table of command options accepted by the C preprocessor.
2746 These options can also be given when compiling a C program; they are
2747 passed along automatically to the preprocessor when it is invoked by the
2748 compiler.
2749
2750 @table @samp
2751 @item -P
2752 @findex -P
2753 Inhibit generation of @samp{#}-lines with line-number information in
2754 the output from the preprocessor (@pxref{Output}).  This might be
2755 useful when running the preprocessor on something that is not C code
2756 and will be sent to a program which might be confused by the
2757 @samp{#}-lines.
2758
2759 @item -C
2760 @findex -C
2761 Do not discard comments: pass them through to the output file.
2762 Comments appearing in arguments of a macro call will be copied to the
2763 output before the expansion of the macro call.
2764
2765 @item -traditional
2766 @findex -traditional
2767 Try to imitate the behavior of old-fashioned C, as opposed to ANSI C@.
2768
2769 @itemize @bullet
2770 @item
2771 Traditional macro expansion pays no attention to singlequote or
2772 doublequote characters; macro argument symbols are replaced by the
2773 argument values even when they appear within apparent string or
2774 character constants.
2775
2776 @item
2777 Traditionally, it is permissible for a macro expansion to end in the
2778 middle of a string or character constant.  The constant continues into
2779 the text surrounding the macro call.
2780
2781 @item
2782 However, traditionally the end of the line terminates a string or
2783 character constant, with no error.
2784
2785 @item
2786 In traditional C, a comment is equivalent to no text at all.  (In ANSI
2787 C, a comment counts as whitespace.)
2788
2789 @item
2790 Traditional C does not have the concept of a ``preprocessing number''.
2791 It considers @samp{1.0e+4} to be three tokens: @samp{1.0e}, @samp{+},
2792 and @samp{4}.
2793
2794 @item
2795 A macro is not suppressed within its own definition, in traditional C@.
2796 Thus, any macro that is used recursively inevitably causes an error.
2797
2798 @item
2799 The character @samp{#} has no special meaning within a macro definition
2800 in traditional C@.
2801
2802 @item
2803 In traditional C, the text at the end of a macro expansion can run
2804 together with the text after the macro call, to produce a single token.
2805 (This is impossible in ANSI C@.)
2806
2807 @item
2808 Traditionally, @samp{\} inside a macro argument suppresses the syntactic
2809 significance of the following character.
2810 @end itemize
2811
2812 @cindex Fortran
2813 @cindex unterminated
2814 Use the @samp{-traditional} option when preprocessing Fortran code,
2815 so that singlequotes and doublequotes
2816 within Fortran comment lines
2817 (which are generally not recognized as such by the preprocessor)
2818 do not cause diagnostics
2819 about unterminated character or string constants.
2820
2821 However, this option does not prevent diagnostics
2822 about unterminated comments
2823 when a C-style comment appears to start, but not end,
2824 within Fortran-style commentary.
2825
2826 So, the following Fortran comment lines are accepted with
2827 @samp{-traditional}:
2828
2829 @smallexample
2830 C This isn't an unterminated character constant
2831 C Neither is "20000000000, an octal constant
2832 C in some dialects of Fortran
2833 @end smallexample
2834
2835 However, this type of comment line will likely produce a diagnostic,
2836 or at least unexpected output from the preprocessor,
2837 due to the unterminated comment:
2838
2839 @smallexample
2840 C Some Fortran compilers accept /* as starting
2841 C an inline comment.
2842 @end smallexample
2843
2844 @cindex g77
2845 Note that @code{g77} automatically supplies
2846 the @samp{-traditional} option
2847 when it invokes the preprocessor.
2848 However, a future version of @code{g77}
2849 might use a different, more-Fortran-aware preprocessor
2850 in place of @code{cpp}.
2851
2852 @item -trigraphs
2853 @findex -trigraphs
2854 Process ANSI standard trigraph sequences.  These are three-character
2855 sequences, all starting with @samp{??}, that are defined by ANSI C to
2856 stand for single characters.  For example, @samp{??/} stands for
2857 @samp{\}, so @samp{'??/n'} is a character constant for a newline.
2858 Strictly speaking, the GNU C preprocessor does not support all
2859 programs in ANSI Standard C unless @samp{-trigraphs} is used, but if
2860 you ever notice the difference it will be with relief.
2861
2862 You don't want to know any more about trigraphs.
2863
2864 @item -pedantic
2865 @findex -pedantic
2866 Issue warnings required by the ANSI C standard in certain cases such
2867 as when text other than a comment follows @samp{#else} or @samp{#endif}.
2868
2869 @item -pedantic-errors
2870 @findex -pedantic-errors
2871 Like @samp{-pedantic}, except that errors are produced rather than
2872 warnings.
2873
2874 @item -Wcomment
2875 @findex -Wcomment
2876 @ignore
2877 @c "Not worth documenting" both singular and plural forms of this
2878 @c option, per RMS.  But also unclear which is better; hence may need to
2879 @c switch this at some future date.  pesch@cygnus.com, 2jan92.
2880 @itemx -Wcomments
2881 (Both forms have the same effect).
2882 @end ignore
2883 Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
2884 comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
2885
2886 @item -Wtrigraphs
2887 @findex -Wtrigraphs
2888 Warn if any trigraphs are encountered (assuming they are enabled).
2889
2890 @item -Wwhite-space
2891 @findex -Wwhite-space
2892 Warn about possible white space confusion, e.g. white space between a
2893 backslash and a newline.
2894
2895 @item -Wall
2896 @findex -Wall
2897 Requests @samp{-Wcomment}, @samp{-Wtrigraphs}, and @samp{-Wwhite-space}
2898 (but not @samp{-Wtraditional} or @samp{-Wundef}).
2899
2900 @item -Wtraditional
2901 @findex -Wtraditional
2902 Warn about certain constructs that behave differently in traditional and
2903 ANSI C@.
2904
2905 @item -Wundef
2906 @findex -Wundef
2907 Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2908
2909 @item -I @var{directory}
2910 @findex -I
2911 Add the directory @var{directory} to the head of the list of
2912 directories to be searched for header files (@pxref{Include Syntax}).
2913 This can be used to override a system header file, substituting your
2914 own version, since these directories are searched before the system
2915 header file directories.  If you use more than one @samp{-I} option,
2916 the directories are scanned in left-to-right order; the standard
2917 system directories come after.
2918
2919 @item -I-
2920 Any directories specified with @samp{-I} options before the @samp{-I-}
2921 option are searched only for the case of @samp{#include "@var{file}"};
2922 they are not searched for @samp{#include <@var{file}>}.
2923
2924 If additional directories are specified with @samp{-I} options after
2925 the @samp{-I-}, these directories are searched for all @samp{#include}
2926 directives.
2927
2928 In addition, the @samp{-I-} option inhibits the use of the current
2929 directory as the first search directory for @samp{#include "@var{file}"}.
2930 Therefore, the current directory is searched only if it is requested
2931 explicitly with @samp{-I.}.  Specifying both @samp{-I-} and @samp{-I.}
2932 allows you to control precisely which directories are searched before
2933 the current one and which are searched after.
2934
2935 @item -nostdinc
2936 @findex -nostdinc
2937 Do not search the standard system directories for header files.
2938 Only the directories you have specified with @samp{-I} options
2939 (and the current directory, if appropriate) are searched.
2940
2941 @item -nostdinc++
2942 @findex -nostdinc++
2943 Do not search for header files in the C++-specific standard directories,
2944 but do still search the other standard directories.
2945 (This option is used when building the C++ library.)
2946
2947 @item -remap
2948 @findex -remap
2949 When searching for a header file in a directory, remap file names if a
2950 file named @file{header.gcc} exists in that directory.  This can be used
2951 to work around limitations of file systems with file name restrictions.
2952 The @file{header.gcc} file should contain a series of lines with two
2953 tokens on each line: the first token is the name to map, and the second
2954 token is the actual name to use.
2955
2956 @item -D @var{name}
2957 @findex -D
2958 Predefine @var{name} as a macro, with definition @samp{1}.
2959
2960 @item -D @var{name}=@var{definition}
2961 Predefine @var{name} as a macro, with definition @var{definition}.
2962 There are no restrictions on the contents of @var{definition}, but if
2963 you are invoking the preprocessor from a shell or shell-like program you
2964 may need to use the shell's quoting syntax to protect characters such as
2965 spaces that have a meaning in the shell syntax.  If you use more than
2966 one @samp{-D} for the same @var{name}, the rightmost definition takes
2967 effect.
2968
2969 @item -U @var{name}
2970 @findex -U
2971 Do not predefine @var{name}.  If both @samp{-U} and @samp{-D} are
2972 specified for one name, whichever one appears later on the command line
2973 wins.
2974
2975 @item -undef
2976 @findex -undef
2977 Do not predefine any nonstandard macros.
2978
2979 @item -gcc
2980 @findex -gcc
2981 Define the macros @var{__GNUC__}, @var{__GNUC_MINOR__} and
2982 @var{__GNUC_PATCHLEVEL__}. These are defined automatically when you use
2983 @samp{gcc -E}; you can turn them off in that case with @samp{-no-gcc}.
2984
2985 @item -A @var{predicate}(@var{answer})
2986 @findex -A
2987 Make an assertion with the predicate @var{predicate} and answer
2988 @var{answer}.  @xref{Assertions}.
2989
2990 @item -A -@var{predicate}(@var{answer})
2991 Disable an assertion with the predicate @var{predicate} and answer
2992 @var{answer}.  Specifiying no predicate, by @samp{-A-} or @samp{-A -},
2993 disables all predefined assertions and all assertions preceding it on
2994 the command line; and also undefines all predefined macros and all
2995 macros preceding it on the command line.
2996
2997 @item -dM
2998 @findex -dM
2999 Instead of outputting the result of preprocessing, output a list of
3000 @samp{#define} directives for all the macros defined during the
3001 execution of the preprocessor, including predefined macros.  This gives
3002 you a way of finding out what is predefined in your version of the
3003 preprocessor; assuming you have no file @samp{foo.h}, the command
3004
3005 @example
3006 touch foo.h; cpp -dM foo.h
3007 @end example
3008
3009 @noindent 
3010 will show the values of any predefined macros.
3011
3012 @item -dD
3013 @findex -dD
3014 Like @samp{-dM} except in two respects: it does @emph{not} include the
3015 predefined macros, and it outputs @emph{both} the @samp{#define}
3016 directives and the result of preprocessing.  Both kinds of output go to
3017 the standard output file.
3018
3019 @item -dI
3020 @findex -dI
3021 Output @samp{#include} directives in addition to the result of preprocessing.
3022
3023 @item -M [-MG]
3024 @findex -M
3025 Instead of outputting the result of preprocessing, output a rule
3026 suitable for @code{make} describing the dependencies of the main
3027 source file.  The preprocessor outputs one @code{make} rule containing
3028 the object file name for that source file, a colon, and the names of
3029 all the included files.  If there are many included files then the
3030 rule is split into several lines using @samp{\}-newline.
3031
3032 @samp{-MG} says to treat missing header files as generated files and assume
3033 they live in the same directory as the source file.  It must be specified
3034 in addition to @samp{-M}.
3035
3036 This feature is used in automatic updating of makefiles.
3037
3038 @item -MM [-MG]
3039 @findex -MM
3040 Like @samp{-M} but mention only the files included with @samp{#include
3041 "@var{file}"}.  System header files included with @samp{#include
3042 <@var{file}>} are omitted.
3043
3044 @item -MD @var{file}
3045 @findex -MD
3046 Like @samp{-M} but the dependency information is written to @var{file}.
3047 This is in addition to compiling the file as specified---@samp{-MD} does
3048 not inhibit ordinary compilation the way @samp{-M} does.
3049
3050 When invoking @code{gcc}, do not specify the @var{file} argument.
3051 @code{gcc} will create file names made by replacing ".c" with ".d" at
3052 the end of the input file names.
3053
3054 In Mach, you can use the utility @code{md} to merge multiple dependency
3055 files into a single dependency file suitable for using with the @samp{make}
3056 command.
3057
3058 @item -MMD @var{file}
3059 @findex -MMD
3060 Like @samp{-MD} except mention only user header files, not system
3061 header files.
3062
3063 @item -H
3064 @findex -H
3065 Print the name of each header file used, in addition to other normal
3066 activities.
3067
3068 @item -imacros @var{file}
3069 @findex -imacros
3070 Process @var{file} as input, discarding the resulting output, before
3071 processing the regular input file.  Because the output generated from
3072 @var{file} is discarded, the only effect of @samp{-imacros @var{file}}
3073 is to make the macros defined in @var{file} available for use in the
3074 main input.
3075
3076 @item -include @var{file}
3077 @findex -include
3078 Process @var{file} as input, and include all the resulting output,
3079 before processing the regular input file.  
3080
3081 @item -idirafter @var{dir}
3082 @findex -idirafter
3083 @cindex second include path
3084 Add the directory @var{dir} to the second include path.  The directories
3085 on the second include path are searched when a header file is not found
3086 in any of the directories in the main include path (the one that
3087 @samp{-I} adds to).
3088
3089 @item -iprefix @var{prefix}
3090 @findex -iprefix
3091 Specify @var{prefix} as the prefix for subsequent @samp{-iwithprefix}
3092 options.
3093
3094 @item -iwithprefix @var{dir}
3095 @findex -iwithprefix
3096 Add a directory to the second include path.  The directory's name is
3097 made by concatenating @var{prefix} and @var{dir}, where @var{prefix}
3098 was specified previously with @samp{-iprefix}.
3099
3100 @item -isystem @var{dir}
3101 @findex -isystem
3102 Add a directory to the beginning of the second include path, marking it
3103 as a system directory, so that it gets the same special treatment as
3104 is applied to the standard system directories.  @xref{System Headers}.
3105
3106 @item -x c
3107 @itemx -x c++
3108 @itemx -x objective-c
3109 @itemx -x assembler-with-cpp
3110 @findex -x c
3111 @findex -x objective-c
3112 @findex -x assembler-with-cpp
3113 Specify the source language: C, C++, Objective-C, or assembly.  This has
3114 nothing to do with standards conformance or extensions; it merely
3115 selects which base syntax to expect.  If you give none of these options,
3116 cpp will deduce the language from the extension of the source file:
3117 @samp{.c}, @samp{.cc}, @samp{.m}, or @samp{.S}.  Some other common
3118 extensions for C++ and assembly are also recognized.  If cpp does not
3119 recognize the extension, it will treat the file as C; this is the most
3120 generic mode.
3121
3122 @strong{Note:} Previous versions of cpp accepted a @samp{-lang} option
3123 which selected both the language and the standards conformance level.
3124 This option has been removed, because it conflicts with the @samp{-l}
3125 option.
3126
3127 @item -std=@var{standard}
3128 @itemx -ansi
3129 @findex -std
3130 @findex -ansi
3131 Specify the standard to which the code should conform.  Currently cpp
3132 only knows about the standards for C; other language standards will be
3133 added in the future.
3134
3135 @var{standard}
3136 may be one of:
3137 @table @code
3138 @item iso9899:1990
3139 The ISO C standard from 1990.
3140
3141 @item iso9899:199409
3142 @itemx c89
3143 The 1990 C standard, as amended in 1994.  @samp{c89} is the customary
3144 shorthand for this version of the standard.
3145
3146 The @samp{-ansi} option is equivalent to @samp{-std=c89}.
3147
3148 @item iso9899:199x
3149 @itemx c9x
3150 The revised ISO C standard, which is expected to be promulgated some
3151 time in 1999.  It has not been approved yet, hence the @samp{x}.
3152
3153 @item gnu89
3154 The 1990 C standard plus GNU extensions.  This is the default.
3155
3156 @item gnu9x
3157 The 199x C standard plus GNU extensions.
3158 @end table
3159
3160 @item -Wp,-lint
3161 @findex -lint
3162 Look for commands to the program checker @code{lint} embedded in
3163 comments, and emit them preceded by @samp{#pragma lint}.  For example,
3164 the comment @samp{/* NOTREACHED */} becomes @samp{#pragma lint
3165 NOTREACHED}.
3166
3167 Because of the clash with @samp{-l}, you must use the awkward syntax
3168 above.  In a future release, this option will be replaced by
3169 @samp{-flint} or @samp{-Wlint}; we are not sure which yet.
3170
3171 @item -ftabstop=NUMBER
3172 @findex -ftabstop
3173 Indicates the distance between tabstops.  This helps the preprocessor
3174 report correct column numbers in warnings or errors, even if tabs appear
3175 on the line.  Values less than 1 or greater than 100 are ignored.  The
3176 default is 8.
3177
3178 @item -$
3179 @findex -$
3180 Forbid the use of @samp{$} in identifiers.  The C standard does not
3181 permit this, but it is a common extension.
3182 @end table
3183 @c man end
3184
3185 @node Concept Index, Index, Invocation, Top
3186 @unnumbered Concept Index
3187 @printindex cp
3188
3189 @node Index,, Concept Index, Top
3190 @unnumbered Index of Directives, Macros and Options
3191 @printindex fn
3192
3193 @contents
3194 @bye