1 This is Info file cpp.info, produced by Makeinfo version 1.67 from the
4 This file documents the GNU C Preprocessor.
6 Copyright 1987, 1989, 1991, 1992, 1993, 1994, 1995 Free Software
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
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
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
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.
60 Try to imitate the behavior of old-fashioned C, as opposed to ANSI
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',
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.
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.
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'.
112 Like `-pedantic', except that errors are produced rather than
116 Warn if any trigraphs are encountered (assuming they are enabled).
119 Warn whenever a comment-start sequence `/*' appears in a `/*'
120 comment, or whenever a Backslash-Newline appears in a `//' comment.
123 Requests both `-Wtrigraphs' and `-Wcomment' (but not
124 `-Wtraditional' or `-Wundef').
127 Warn about certain constructs that behave differently in
128 traditional and ANSI C.
131 Warn if an undefined identifier is evaluated in an `#if' directive.
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.
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'
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.
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.
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 libg++.)
169 Predefine NAME as a macro, with definition `1'.
172 Predefine NAME as a macro, with definition DEFINITION. There are
173 no restrictions on the contents of DEFINITION, but if you are
174 invoking the preprocessor from a shell or shell-like program you
175 may need to use the shell's quoting syntax to protect characters
176 such as spaces that have a meaning in the shell syntax. If you
177 use more than one `-D' for the same NAME, the rightmost definition
181 Do not predefine NAME. If both `-U' and `-D' are specified for
182 one name, the `-U' beats the `-D' and the name is not predefined.
185 Do not predefine any nonstandard macros.
187 `-A PREDICATE(ANSWER)'
188 Make an assertion with the predicate PREDICATE and answer ANSWER.
191 You can use `-A-' to disable all predefined assertions; it also
192 undefines all predefined macros that identify the type of target
196 Instead of outputting the result of preprocessing, output a list of
197 `#define' directives for all the macros defined during the
198 execution of the preprocessor, including predefined macros. This
199 gives you a way of finding out what is predefined in your version
200 of the preprocessor; assuming you have no file `foo.h', the command
202 touch foo.h; cpp -dM foo.h
204 will show the values of any predefined macros.
207 Like `-dM' except in two respects: it does *not* include the
208 predefined macros, and it outputs *both* the `#define' directives
209 and the result of preprocessing. Both kinds of output go to the
210 standard output file.
213 Output `#include' directives in addition to the result of
217 Instead of outputting the result of preprocessing, output a rule
218 suitable for `make' describing the dependencies of the main source
219 file. The preprocessor outputs one `make' rule containing the
220 object file name for that source file, a colon, and the names of
221 all the included files. If there are many included files then the
222 rule is split into several lines using `\'-newline.
224 `-MG' says to treat missing header files as generated files and
225 assume they live in the same directory as the source file. It
226 must be specified in addition to `-M'.
228 This feature is used in automatic updating of makefiles.
231 Like `-M' but mention only the files included with `#include
232 "FILE"'. System header files included with `#include <FILE>' are
236 Like `-M' but the dependency information is written to FILE. This
237 is in addition to compiling the file as specified--`-MD' does not
238 inhibit ordinary compilation the way `-M' does.
240 When invoking gcc, do not specify the FILE argument. Gcc will
241 create file names made by replacing ".c" with ".d" at the end of
242 the input file names.
244 In Mach, you can use the utility `md' to merge multiple dependency
245 files into a single dependency file suitable for using with the
249 Like `-MD' except mention only user header files, not system
253 Print the name of each header file used, in addition to other
257 Process FILE as input, discarding the resulting output, before
258 processing the regular input file. Because the output generated
259 from FILE is discarded, the only effect of `-imacros FILE' is to
260 make the macros defined in FILE available for use in the main
264 Process FILE as input, and include all the resulting output,
265 before processing the regular input file.
268 Add the directory DIR to the second include path. The directories
269 on the second include path are searched when a header file is not
270 found in any of the directories in the main include path (the one
274 Specify PREFIX as the prefix for subsequent `-iwithprefix' options.
277 Add a directory to the second include path. The directory's name
278 is made by concatenating PREFIX and DIR, where PREFIX was
279 specified previously with `-iprefix'.
282 Add a directory to the beginning of the second include path,
283 marking it as a system directory, so that it gets the same special
284 treatment as is applied to the standard system directories.
291 Specify the source language. `-lang-c' is the default; it allows
292 recognition of C++ comments (comments that begin with `//' and end
293 at end of line) and hexadecimal floating-point constants, since
294 these features will most likely appear in the next C standard.
295 `-lang-c89' disables recognition of C++ comments and hexadecimal
296 floating-point constants. `-lang-c++' handles C++ comment syntax
297 and includes extra default include directories for C++.
298 `-lang-objc' enables the Objective C `#import' directive.
299 `-lang-objc++' enables both C++ and Objective C extensions.
301 These options are generated by the compiler driver `gcc', but not
302 passed from the `gcc' command line unless you use the driver's
306 Look for commands to the program checker `lint' embedded in
307 comments, and emit them preceded by `#pragma lint'. For example,
308 the comment `/* NOTREACHED */' becomes `#pragma lint NOTREACHED'.
310 This option is available only when you call `cpp' directly; `gcc'
311 will not pass it from its command line.
314 Forbid the use of `$' in identifiers. This was formerly required
315 for strict conformance to the C Standard before the standard was
318 This option is available only when you call `cpp' directly; `gcc'
319 will not pass it from its command line.
322 File: cpp.info, Node: Concept Index, Next: Index, Prev: Invocation, Up: Top
330 * arguments in macro definitions: Argument Macros.
331 * assertions: Assertions.
332 * assertions, undoing: Assertions.
333 * blank macro arguments: Argument Macros.
334 * cascaded macros: Cascaded Macros.
335 * commenting out code: Deleted Code.
336 * computed #include: Include Syntax.
337 * concatenation: Concatenation.
338 * conditionals: Conditionals.
339 * directives: Directives.
340 * expansion of arguments: Argument Prescan.
341 * function-like macro: Argument Macros.
342 * header file: Header Files.
343 * including just once: Once-Only.
344 * inheritance: Inheritance.
345 * invocation of the preprocessor: Invocation.
346 * line control: Combining Sources.
347 * macro argument expansion: Argument Prescan.
348 * macro body uses macro: Cascaded Macros.
349 * macros with argument: Argument Macros.
350 * manifest constant: Simple Macros.
351 * newlines in macro arguments: Newlines in Args.
352 * null directive: Other Directives.
353 * options: Invocation.
354 * output format: Output.
355 * overriding a header file: Inheritance.
356 * parentheses in macro bodies: Macro Parentheses.
357 * pitfalls of macros: Macro Pitfalls.
358 * predefined macros: Predefined.
359 * predicates: Assertions.
360 * preprocessing directives: Directives.
361 * prescan of macro arguments: Argument Prescan.
362 * problems with macros: Macro Pitfalls.
363 * redefining macros: Redefining.
364 * repeated inclusion: Once-Only.
365 * retracting assertions: Assertions.
366 * second include path: Invocation.
367 * self-reference: Self-Reference.
368 * semicolons (after macro calls): Swallow Semicolon.
369 * side effects (in macro arguments): Side Effects.
370 * simple macro: Simple Macros.
371 * space as macro argument: Argument Macros.
372 * standard predefined macros: Standard Predefined.
373 * stringification: Stringification.
374 * testing predicates: Assertions.
375 * unassert: Assertions.
376 * undefining macros: Undefining.
377 * unsafe macros: Side Effects.
380 File: cpp.info, Node: Index, Prev: Concept Index, Up: Top
382 Index of Directives, Macros and Options
383 ***************************************
387 * #assert: Assertions.
389 * #define: Argument Macros.
390 * #elif: #elif Directive.
391 * #else: #else Directive.
392 * #error: #error Directive.
393 * #ident: Other Directives.
394 * #if: Conditional Syntax.
395 * #ifdef: Conditionals-Macros.
396 * #ifndef: Conditionals-Macros.
397 * #import: Once-Only.
398 * #include: Include Syntax.
399 * #include_next: Inheritance.
400 * #line: Combining Sources.
401 * #machine: Assertions.
402 * #pragma: Other Directives.
403 * #pragma once: Once-Only.
404 * #system: Assertions.
405 * #unassert: Assertions.
406 * #warning: #error Directive.
416 * -idirafter: Invocation.
417 * -imacros: Invocation.
418 * -include: Invocation.
419 * -iprefix: Invocation.
420 * -isystem: Invocation.
421 * -iwithprefix: Invocation.
422 * -lang-c: Invocation.
423 * -lang-c++: Invocation.
424 * -lang-c89: Invocation.
425 * -lang-objc: Invocation.
426 * -lang-objc++: Invocation.
431 * -nostdinc: Invocation.
432 * -nostdinc++: Invocation.
434 * -pedantic: Invocation.
435 * -pedantic-errors: Invocation.
436 * -traditional: Invocation.
437 * -trigraphs: Invocation.
439 * -undef: Invocation.
441 * -Wcomment: Invocation.
442 * -Wtraditional: Invocation.
443 * -Wtrigraphs: Invocation.
444 * -Wundef: Invocation.
445 * __BASE_FILE__: Standard Predefined.
446 * __CHAR_UNSIGNED__: Standard Predefined.
447 * __cplusplus: Standard Predefined.
448 * __DATE__: Standard Predefined.
449 * __FILE__: Standard Predefined.
450 * __GNUC__: Standard Predefined.
451 * __GNUC_MINOR__: Standard Predefined.
452 * __GNUG__: Standard Predefined.
453 * __INCLUDE_LEVEL_: Standard Predefined.
454 * __LINE__: Standard Predefined.
455 * __OPTIMIZE__: Standard Predefined.
456 * __REGISTER_PREFIX__: Standard Predefined.
457 * __STDC__: Standard Predefined.
458 * __STDC_VERSION__: Standard Predefined.
459 * __STRICT_ANSI__: Standard Predefined.
460 * __TIME__: Standard Predefined.
461 * __USER_LABEL_PREFIX__: Standard Predefined.
462 * __VERSION__: Standard Predefined.
463 * _AM29000: Nonstandard Predefined.
464 * _AM29K: Nonstandard Predefined.
465 * BSD: Nonstandard Predefined.
466 * defined: Conditionals-Macros.
467 * M68020: Nonstandard Predefined.
468 * m68k: Nonstandard Predefined.
469 * mc68000: Nonstandard Predefined.
470 * ns32000: Nonstandard Predefined.
471 * pyr: Nonstandard Predefined.
472 * sequent: Nonstandard Predefined.
473 * sun: Nonstandard Predefined.
474 * system header files: Header Uses.
475 * unix: Nonstandard Predefined.
476 * vax: Nonstandard Predefined.