Import gcc-2.8.1.tar.bz2
[official-gcc.git] / gcc / cpp.info-3
blob81e62fd967215c20ed5948b9b2d8e3ec661fea3b
1 This is Info file cpp.info, produced by Makeinfo version 1.67 from the
2 input file cpp.texi.
4    This file documents the GNU C Preprocessor.
6    Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software
7 Foundation, Inc.
9    Permission is granted to make and distribute verbatim copies of this
10 manual provided the copyright notice and this permission notice are
11 preserved on all copies.
13    Permission is granted to copy and distribute modified versions of
14 this manual under the conditions for verbatim copying, provided also
15 that the entire resulting derived work is distributed under the terms
16 of a permission notice identical to this one.
18    Permission is granted to copy and distribute translations of this
19 manual into another language, under the above conditions for modified
20 versions.
22 \x1f
23 File: cpp.info,  Node: Invocation,  Next: Concept Index,  Prev: Output,  Up: Top
25 Invoking the C Preprocessor
26 ===========================
28    Most often when you use the C preprocessor you will not have to
29 invoke it explicitly: the C compiler will do so automatically.
30 However, the preprocessor is sometimes useful on its own.
32    The C preprocessor expects two file names as arguments, INFILE and
33 OUTFILE.  The preprocessor reads INFILE together with any other files
34 it specifies with `#include'.  All the output generated by the combined
35 input files is written in OUTFILE.
37    Either INFILE or OUTFILE may be `-', which as INFILE means to read
38 from standard input and as OUTFILE means to write to standard output.
39 Also, if OUTFILE or both file names are omitted, the standard output
40 and standard input are used for the omitted file names.
42    Here is a table of command options accepted by the C preprocessor.
43 These options can also be given when compiling a C program; they are
44 passed along automatically to the preprocessor when it is invoked by the
45 compiler.
47 `-P'
48      Inhibit generation of `#'-lines with line-number information in
49      the output from the preprocessor (*note Output::.).  This might be
50      useful when running the preprocessor on something that is not C
51      code and will be sent to a program which might be confused by the
52      `#'-lines.
54 `-C'
55      Do not discard comments: pass them through to the output file.
56      Comments appearing in arguments of a macro call will be copied to
57      the output before the expansion of the macro call.
59 `-traditional'
60      Try to imitate the behavior of old-fashioned C, as opposed to ANSI
61      C.
63         * Traditional macro expansion pays no attention to singlequote
64           or doublequote characters; macro argument symbols are
65           replaced by the argument values even when they appear within
66           apparent string or character constants.
68         * Traditionally, it is permissible for a macro expansion to end
69           in the middle of a string or character constant.  The
70           constant continues into the text surrounding the macro call.
72         * However, traditionally the end of the line terminates a
73           string or character constant, with no error.
75         * In traditional C, a comment is equivalent to no text at all.
76           (In ANSI C, a comment counts as whitespace.)
78         * Traditional C does not have the concept of a "preprocessing
79           number".  It considers `1.0e+4' to be three tokens: `1.0e',
80           `+', and `4'.
82         * A macro is not suppressed within its own definition, in
83           traditional C.  Thus, any macro that is used recursively
84           inevitably causes an error.
86         * The character `#' has no special meaning within a macro
87           definition in traditional C.
89         * In traditional C, the text at the end of a macro expansion
90           can run together with the text after the macro call, to
91           produce a single token.  (This is impossible in ANSI C.)
93         * Traditionally, `\' inside a macro argument suppresses the
94           syntactic significance of the following character.
96 `-trigraphs'
97      Process ANSI standard trigraph sequences.  These are
98      three-character sequences, all starting with `??', that are
99      defined by ANSI C to stand for single characters.  For example,
100      `??/' stands for `\', so `'??/n'' is a character constant for a
101      newline.  Strictly speaking, the GNU C preprocessor does not
102      support all programs in ANSI Standard C unless `-trigraphs' is
103      used, but if you ever notice the difference it will be with relief.
105      You don't want to know any more about trigraphs.
107 `-pedantic'
108      Issue warnings required by the ANSI C standard in certain cases
109      such as when text other than a comment follows `#else' or `#endif'.
111 `-pedantic-errors'
112      Like `-pedantic', except that errors are produced rather than
113      warnings.
115 `-Wtrigraphs'
116      Warn if any trigraphs are encountered (assuming they are enabled).
118 `-Wcomment'
119      Warn whenever a comment-start sequence `/*' appears in a `/*'
120      comment, or whenever a Backslash-Newline appears in a `//' comment.
122 `-Wall'
123      Requests both `-Wtrigraphs' and `-Wcomment' (but not
124      `-Wtraditional' or `-Wundef').
126 `-Wtraditional'
127      Warn about certain constructs that behave differently in
128      traditional and ANSI C.
130 `-Wundef'
131      Warn if an undefined identifier is evaluated in an `#if' directive.
133 `-I DIRECTORY'
134      Add the directory DIRECTORY to the head of the list of directories
135      to be searched for header files (*note Include Syntax::.).  This
136      can be used to override a system header file, substituting your
137      own version, since these directories are searched before the system
138      header file directories.  If you use more than one `-I' option,
139      the directories are scanned in left-to-right order; the standard
140      system directories come after.
142 `-I-'
143      Any directories specified with `-I' options before the `-I-'
144      option are searched only for the case of `#include "FILE"'; they
145      are not searched for `#include <FILE>'.
147      If additional directories are specified with `-I' options after
148      the `-I-', these directories are searched for all `#include'
149      directives.
151      In addition, the `-I-' option inhibits the use of the current
152      directory as the first search directory for `#include "FILE"'.
153      Therefore, the current directory is searched only if it is
154      requested explicitly with `-I.'.  Specifying both `-I-' and `-I.'
155      allows you to control precisely which directories are searched
156      before the current one and which are searched after.
158 `-nostdinc'
159      Do not search the standard system directories for header files.
160      Only the directories you have specified with `-I' options (and the
161      current directory, if appropriate) are searched.
163 `-nostdinc++'
164      Do not search for header files in the C++-specific standard
165      directories, but do still search the other standard directories.
166      (This option is used when building the C++ library.)
168 `-remap'
169      When searching for a header file in a directory, remap file names
170      if a file named `header.gcc' exists in that directory.  This can
171      be used to work around limitations of file systems with file name
172      restrictions.  The `header.gcc' file should contain a series of
173      lines with two tokens on each line: the first token is the name to
174      map, and the second token is the actual name to use.
176 `-D NAME'
177      Predefine NAME as a macro, with definition `1'.
179 `-D NAME=DEFINITION'
180      Predefine NAME as a macro, with definition DEFINITION.  There are
181      no restrictions on the contents of DEFINITION, but if you are
182      invoking the preprocessor from a shell or shell-like program you
183      may need to use the shell's quoting syntax to protect characters
184      such as spaces that have a meaning in the shell syntax.  If you
185      use more than one `-D' for the same NAME, the rightmost definition
186      takes effect.
188 `-U NAME'
189      Do not predefine NAME.  If both `-U' and `-D' are specified for
190      one name, the `-U' beats the `-D' and the name is not predefined.
192 `-undef'
193      Do not predefine any nonstandard macros.
195 `-A PREDICATE(ANSWER)'
196      Make an assertion with the predicate PREDICATE and answer ANSWER.
197      *Note Assertions::.
199      You can use `-A-' to disable all predefined assertions; it also
200      undefines all predefined macros that identify the type of target
201      system.
203 `-dM'
204      Instead of outputting the result of preprocessing, output a list of
205      `#define' directives for all the macros defined during the
206      execution of the preprocessor, including predefined macros.  This
207      gives you a way of finding out what is predefined in your version
208      of the preprocessor; assuming you have no file `foo.h', the command
210           touch foo.h; cpp -dM foo.h
212      will show the values of any predefined macros.
214 `-dD'
215      Like `-dM' except in two respects: it does *not* include the
216      predefined macros, and it outputs *both* the `#define' directives
217      and the result of preprocessing.  Both kinds of output go to the
218      standard output file.
220 `-dI'
221      Output `#include' directives in addition to the result of
222      preprocessing.
224 `-M [-MG]'
225      Instead of outputting the result of preprocessing, output a rule
226      suitable for `make' describing the dependencies of the main source
227      file.  The preprocessor outputs one `make' rule containing the
228      object file name for that source file, a colon, and the names of
229      all the included files.  If there are many included files then the
230      rule is split into several lines using `\'-newline.
232      `-MG' says to treat missing header files as generated files and
233      assume they live in the same directory as the source file.  It
234      must be specified in addition to `-M'.
236      This feature is used in automatic updating of makefiles.
238 `-MM [-MG]'
239      Like `-M' but mention only the files included with `#include
240      "FILE"'.  System header files included with `#include <FILE>' are
241      omitted.
243 `-MD FILE'
244      Like `-M' but the dependency information is written to FILE.  This
245      is in addition to compiling the file as specified--`-MD' does not
246      inhibit ordinary compilation the way `-M' does.
248      When invoking gcc, do not specify the FILE argument.  Gcc will
249      create file names made by replacing ".c" with ".d" at the end of
250      the input file names.
252      In Mach, you can use the utility `md' to merge multiple dependency
253      files into a single dependency file suitable for using with the
254      `make' command.
256 `-MMD FILE'
257      Like `-MD' except mention only user header files, not system
258      header files.
260 `-H'
261      Print the name of each header file used, in addition to other
262      normal activities.
264 `-imacros FILE'
265      Process FILE as input, discarding the resulting output, before
266      processing the regular input file.  Because the output generated
267      from FILE is discarded, the only effect of `-imacros FILE' is to
268      make the macros defined in FILE available for use in the main
269      input.
271 `-include FILE'
272      Process FILE as input, and include all the resulting output,
273      before processing the regular input file.
275 `-idirafter DIR'
276      Add the directory DIR to the second include path.  The directories
277      on the second include path are searched when a header file is not
278      found in any of the directories in the main include path (the one
279      that `-I' adds to).
281 `-iprefix PREFIX'
282      Specify PREFIX as the prefix for subsequent `-iwithprefix' options.
284 `-iwithprefix DIR'
285      Add a directory to the second include path.  The directory's name
286      is made by concatenating PREFIX and DIR, where PREFIX was
287      specified previously with `-iprefix'.
289 `-isystem DIR'
290      Add a directory to the beginning of the second include path,
291      marking it as a system directory, so that it gets the same special
292      treatment as is applied to the standard system directories.
294 `-lang-c'
295 `-lang-c89'
296 `-lang-c++'
297 `-lang-objc'
298 `-lang-objc++'
299      Specify the source language.  `-lang-c' is the default; it allows
300      recognition of C++ comments (comments that begin with `//' and end
301      at end of line) and hexadecimal floating-point constants, since
302      these features will most likely appear in the next C standard.
303      `-lang-c89' disables recognition of C++ comments and hexadecimal
304      floating-point constants.  `-lang-c++' handles C++ comment syntax
305      and includes extra default include directories for C++.
306      `-lang-objc' enables the Objective C `#import' directive.
307      `-lang-objc++' enables both C++ and Objective C extensions.
309      These options are generated by the compiler driver `gcc', but not
310      passed from the `gcc' command line unless you use the driver's
311      `-Wp' option.
313 `-lint'
314      Look for commands to the program checker `lint' embedded in
315      comments, and emit them preceded by `#pragma lint'.  For example,
316      the comment `/* NOTREACHED */' becomes `#pragma lint NOTREACHED'.
318      This option is available only when you call `cpp' directly; `gcc'
319      will not pass it from its command line.
321 `-$'
322      Forbid the use of `$' in identifiers.  This was formerly required
323      for strict conformance to the C Standard before the standard was
324      corrected.
326      This option is available only when you call `cpp' directly; `gcc'
327      will not pass it from its command line.
329 \x1f
330 File: cpp.info,  Node: Concept Index,  Next: Index,  Prev: Invocation,  Up: Top
332 Concept Index
333 *************
335 * Menu:
337 * ##:                                    Concatenation.
338 * arguments in macro definitions:        Argument Macros.
339 * assertions:                            Assertions.
340 * assertions, undoing:                   Assertions.
341 * blank macro arguments:                 Argument Macros.
342 * cascaded macros:                       Cascaded Macros.
343 * commenting out code:                   Deleted Code.
344 * computed #include:                     Include Syntax.
345 * concatenation:                         Concatenation.
346 * conditionals:                          Conditionals.
347 * directives:                            Directives.
348 * expansion of arguments:                Argument Prescan.
349 * function-like macro:                   Argument Macros.
350 * header file:                           Header Files.
351 * including just once:                   Once-Only.
352 * inheritance:                           Inheritance.
353 * invocation of the preprocessor:        Invocation.
354 * line control:                          Combining Sources.
355 * macro argument expansion:              Argument Prescan.
356 * macro body uses macro:                 Cascaded Macros.
357 * macros with argument:                  Argument Macros.
358 * manifest constant:                     Simple Macros.
359 * newlines in macro arguments:           Newlines in Args.
360 * null directive:                        Other Directives.
361 * options:                               Invocation.
362 * output format:                         Output.
363 * overriding a header file:              Inheritance.
364 * parentheses in macro bodies:           Macro Parentheses.
365 * pitfalls of macros:                    Macro Pitfalls.
366 * predefined macros:                     Predefined.
367 * predicates:                            Assertions.
368 * preprocessing directives:              Directives.
369 * prescan of macro arguments:            Argument Prescan.
370 * problems with macros:                  Macro Pitfalls.
371 * redefining macros:                     Redefining.
372 * repeated inclusion:                    Once-Only.
373 * retracting assertions:                 Assertions.
374 * second include path:                   Invocation.
375 * self-reference:                        Self-Reference.
376 * semicolons (after macro calls):        Swallow Semicolon.
377 * side effects (in macro arguments):     Side Effects.
378 * simple macro:                          Simple Macros.
379 * space as macro argument:               Argument Macros.
380 * standard predefined macros:            Standard Predefined.
381 * stringification:                       Stringification.
382 * testing predicates:                    Assertions.
383 * unassert:                              Assertions.
384 * undefining macros:                     Undefining.
385 * unsafe macros:                         Side Effects.
387 \x1f
388 File: cpp.info,  Node: Index,  Prev: Concept Index,  Up: Top
390 Index of Directives, Macros and Options
391 ***************************************
393 * Menu:
395 * #assert:                               Assertions.
396 * #cpu:                                  Assertions.
397 * #define:                               Argument Macros.
398 * #elif:                                 #elif Directive.
399 * #else:                                 #else Directive.
400 * #error:                                #error Directive.
401 * #ident:                                Other Directives.
402 * #if:                                   Conditional Syntax.
403 * #ifdef:                                Conditionals-Macros.
404 * #ifndef:                               Conditionals-Macros.
405 * #import:                               Once-Only.
406 * #include:                              Include Syntax.
407 * #include_next:                         Inheritance.
408 * #line:                                 Combining Sources.
409 * #machine:                              Assertions.
410 * #pragma:                               Other Directives.
411 * #pragma once:                          Once-Only.
412 * #system:                               Assertions.
413 * #unassert:                             Assertions.
414 * #warning:                              #error Directive.
415 * -$:                                    Invocation.
416 * -A:                                    Invocation.
417 * -C:                                    Invocation.
418 * -D:                                    Invocation.
419 * -dD:                                   Invocation.
420 * -dI:                                   Invocation.
421 * -dM:                                   Invocation.
422 * -H:                                    Invocation.
423 * -I:                                    Invocation.
424 * -idirafter:                            Invocation.
425 * -imacros:                              Invocation.
426 * -include:                              Invocation.
427 * -iprefix:                              Invocation.
428 * -isystem:                              Invocation.
429 * -iwithprefix:                          Invocation.
430 * -lang-c:                               Invocation.
431 * -lang-c++:                             Invocation.
432 * -lang-c89:                             Invocation.
433 * -lang-objc:                            Invocation.
434 * -lang-objc++:                          Invocation.
435 * -M:                                    Invocation.
436 * -MD:                                   Invocation.
437 * -MM:                                   Invocation.
438 * -MMD:                                  Invocation.
439 * -nostdinc:                             Invocation.
440 * -nostdinc++:                           Invocation.
441 * -P:                                    Invocation.
442 * -pedantic:                             Invocation.
443 * -pedantic-errors:                      Invocation.
444 * -remap:                                Invocation.
445 * -traditional:                          Invocation.
446 * -trigraphs:                            Invocation.
447 * -U:                                    Invocation.
448 * -undef:                                Invocation.
449 * -Wall:                                 Invocation.
450 * -Wcomment:                             Invocation.
451 * -Wtraditional:                         Invocation.
452 * -Wtrigraphs:                           Invocation.
453 * -Wundef:                               Invocation.
454 * __BASE_FILE__:                         Standard Predefined.
455 * __CHAR_UNSIGNED__:                     Standard Predefined.
456 * __cplusplus:                           Standard Predefined.
457 * __DATE__:                              Standard Predefined.
458 * __FILE__:                              Standard Predefined.
459 * __GNUC__:                              Standard Predefined.
460 * __GNUC_MINOR__:                        Standard Predefined.
461 * __GNUG__:                              Standard Predefined.
462 * __INCLUDE_LEVEL_:                      Standard Predefined.
463 * __LINE__:                              Standard Predefined.
464 * __OPTIMIZE__:                          Standard Predefined.
465 * __REGISTER_PREFIX__:                   Standard Predefined.
466 * __STDC__:                              Standard Predefined.
467 * __STDC_VERSION__:                      Standard Predefined.
468 * __STRICT_ANSI__:                       Standard Predefined.
469 * __TIME__:                              Standard Predefined.
470 * __USER_LABEL_PREFIX__:                 Standard Predefined.
471 * __VERSION__:                           Standard Predefined.
472 * _AM29000:                              Nonstandard Predefined.
473 * _AM29K:                                Nonstandard Predefined.
474 * BSD:                                   Nonstandard Predefined.
475 * defined:                               Conditionals-Macros.
476 * M68020:                                Nonstandard Predefined.
477 * m68k:                                  Nonstandard Predefined.
478 * mc68000:                               Nonstandard Predefined.
479 * ns32000:                               Nonstandard Predefined.
480 * pyr:                                   Nonstandard Predefined.
481 * sequent:                               Nonstandard Predefined.
482 * sun:                                   Nonstandard Predefined.
483 * system header files:                   Header Uses.
484 * unix:                                  Nonstandard Predefined.
485 * vax:                                   Nonstandard Predefined.