[Main]
Title=Options Controlling the Preprocessor

[Top]
These options control the <A HREF="$$INFOLINK(cpp)">C preprocessor</A>, which is run on each C source
file before actual compilation.
<BR><BR>
If you use the <B>'-E'</B> option, nothing is done except preprocessing.
Some of these options make sense only together with <B>'-E'</B> because
they cause the preprocessor output to be unsuitable for actual
compilation.
<BR><BR>
You can use <B>'-Wp,<I>option</I>'</B> to bypass the compiler driver
and pass <I>option</I> directly through to the preprocessor.  If
<I>option</I> contains commas, it is split into multiple options at the
commas.  However, many options are modified, translated or interpreted
by the compiler driver before being passed to the preprocessor, and
<B>'-Wp'</B> forcibly bypasses this phase.  The preprocessor's direct
interface is undocumented and subject to change, so whenever possible
you should avoid using <B>'-Wp'</B> and let the driver handle the
options instead.
<DL>
<DT><B>-D <I>name</I></B>
<DD>Predefine <I>name</I> as a macro, with definition <CODE>1</CODE>.
<BR><BR>
<DT><B>-D <I>name</I>=<I>definition</I></B>
<DD>Predefine <I>name</I> as a macro, with definition <I>definition</I>.
There are no restrictions on the contents of <I>definition</I>, but if
you are invoking the preprocessor from a shell or shell-like program you
may need to use the shell's quoting syntax to protect characters such as
spaces that have a meaning in the shell syntax.
<BR><BR>
If you wish to define a function-like macro on the command line, write
its argument list with surrounding parentheses before the equals sign
(if any).  Parentheses are meaningful to most shells, so you will need
to quote the option.  With <CODE>sh</CODE> and <CODE>csh</CODE>,
<B>'-D'<I>name</I>(<I>args...</I>)=<I>definition</I>''</B> works.
<BR><BR>
<B>'-D'</B> and <B>'-U'</B> options are processed in the order they
are given on the command line.  All <B>'-imacros <I>file</I>'</B> and
<B>'-include <I>file</I>'</B> options are processed after all
<B>'-D'</B> and <B>'-U'</B> options.
<BR><BR>
<DT><B>-U <I>name</I></B>
<DD>Cancel any previous definition of <I>name</I>, either built in or
provided with a <B>'-D'</B> option.
<BR><BR>
<DT><B>-undef</B>
<DD>Do not predefine any system-specific macros.  The common predefined
macros remain defined.
<BR><BR>
<DT><B>-I <I>dir</I></B>
<DD>Add the directory <I>dir</I> to the list of directories to be searched
for header files.
Directories named by <B>'-I'</B> are searched before the standard
system include directories.  If the directory <I>dir</I> is a standard
system include directory, the option is ignored to ensure that the
default search order for system directories and the special treatment
of system headers are not defeated
(see <A HREF="$$INFOLINK(cpp/SEC9a)">System Headers</A>).
<BR><BR>
<DT><B>-o <I>file</I></B>
<DD>Write output to <I>file</I>.  This is the same as specifying <I>file</I>
as the second non-option argument to <CODE>cpp</CODE>.  <CODE>gcc</CODE> has a
different interpretation of a second non-option argument, so you must
use <B>'-o'</B> to specify the output file.
<BR><BR>
<DT><B>-Wall</B>
<DD>Turns on all optional warnings which are desirable for normal code.  At
present this is <B>'-Wcomment'</B> and <B>'-Wtrigraphs'</B>.  Note that
many of the preprocessor's warnings are on by default and have no
options to control them.
<BR><BR>
<DT><B>-Wcomment</B>
<BR><B>-Wcomments</B>
<DD>Warn whenever a comment-start sequence <CODE>/*</CODE> appears in a <CODE>/*</CODE>
comment, or whenever a backslash-newline appears in a <CODE>//</CODE> comment.
(Both forms have the same effect.)
<BR><BR>
<DT><B>-Wtrigraphs</B>
<DD>Warn if any trigraphs are encountered.  This option used to take effect
only if <B>'-trigraphs'</B> was also specified, but now works
independently.  Warnings are not given for trigraphs within comments, as
they do not affect the meaning of the program.
<BR><BR>
<DT><B>-Wtraditional</B>
<DD>Warn about certain constructs that behave differently in traditional and
ISO C.  Also warn about ISO C constructs that have no traditional C
equivalent, and problematic constructs which should be avoided.
See <A HREF="$$INFOLINK(cpp/SEC70)">Traditional Mode</A>.
<BR><BR>
<DT><B>-Wimport</B>
<DD>Warn the first time <CODE>#import</CODE> is used.
<BR><BR>
<DT><B>-Wundef</B>
<DD>Warn whenever an identifier which is not a macro is encountered in an
<CODE>#if</CODE> directive, outside of <CODE>defined</CODE>.  Such identifiers are
replaced with zero.
<BR><BR>
<DT><B>-Wunused-macros</B>
<DD>Warn about macros defined in the main file that are unused.  A macro
is <U>used</U> if it is expanded or tested for existence at least once.
The preprocessor will also warn if the macro has not been used at the
time it is redefined or undefined.
<BR><BR>
Built-in macros, macros defined on the command line, and macros
defined in include files are not warned about.
<BR><BR>
<B>Note:</B> If a macro is actually used, but only used in skipped
conditional blocks, then CPP will report it as unused.  To avoid the
warning in such a case, you might improve the scope of the macro's
definition by, for example, moving it into the first skipped block.
Alternatively, you could provide a dummy use with something like:
<PRE>#if defined the_macro_causing_the_warning
#endif
</PRE>
<DT><B>-Wendif-labels</B>
<DD>Warn whenever an <CODE>#else</CODE> or an <CODE>#endif</CODE> are followed by text.
This usually happens in code of the form
<PRE>#if FOO
...
#else FOO
...
#endif FOO
</PRE>
The second and third <CODE>FOO</CODE> should be in comments, but often are not
in older programs.  This warning is on by default.
<BR><BR>
<DT><B>-Werror</B>
<DD>Make all warnings into hard errors.  Source code which triggers warnings
will be rejected.
<BR><BR>
<DT><B>-Wsystem-headers</B>
<DD>Issue warnings for code in system headers.  These are normally unhelpful
in finding bugs in your own code, therefore suppressed.  If you are
responsible for the system library, you may want to see them.
<BR><BR>
<DT><B>-w</B>
<DD>Suppress all warnings, including those which GNU CPP issues by default.
<BR><BR>
<DT><B>-pedantic</B>
<DD>Issue all the mandatory diagnostics listed in the C standard.  Some of
them are left out by default, since they trigger frequently on harmless
code.
<BR><BR>
<DT><B>-pedantic-errors</B>
<DD>Issue all the mandatory diagnostics, and make all mandatory diagnostics
into errors.  This includes mandatory diagnostics that GCC issues
without <B>'-pedantic'</B> but treats as warnings.
<BR><BR>
<DT><B>-M</B>
<DD>Instead of outputting the result of preprocessing, output a rule
suitable for <CODE>make</CODE> describing the dependencies of the main
source file.  The preprocessor outputs one <CODE>make</CODE> rule containing
the object file name for that source file, a colon, and the names of all
the included files, including those coming from <B>'-include'</B> or
<B>'-imacros'</B> command line options.
<BR><BR>
Unless specified explicitly (with <B>'-MT'</B> or <B>'-MQ'</B>), the
object file name consists of the basename of the source file with any
suffix replaced with object file suffix.  If there are many included
files then the rule is split into several lines using <CODE>\</CODE>-newline.
The rule has no commands.
<BR><BR>
This option does not suppress the preprocessor's debug output, such as
<B>'-dM'</B>.  To avoid mixing such debug output with the dependency
rules you should explicitly specify the dependency output file with
<B>'-MF'</B>, or use an environment variable like
<CODE>DEPENDENCIES_OUTPUT</CODE> (see <A HREF="$$INFOLINK(cpp/SEC45)">Environment Variables</A>).  Debug output
will still be sent to the regular output stream as normal.
<BR><BR>
Passing <B>'-M'</B> to the driver implies <B>'-E'</B>, and suppresses
warnings with an implicit <B>'-w'</B>.
<BR><BR>
<DT><B>-MM</B>
<DD>Like <B>'-M'</B> but do not mention header files that are found in
system header directories, nor header files that are included,
directly or indirectly, from such a header.
<BR><BR>
This implies that the choice of angle brackets or double quotes in an
<CODE>#include</CODE> directive does not in itself determine whether that
header will appear in <B>'-MM'</B> dependency output.  This is a
slight change in semantics from GCC versions 3.0 and earlier.
<BR><BR>
<DT><B>-MF <I>file</I></B>
<DD>
When used with <B>'-M'</B> or <B>'-MM'</B>, specifies a
file to write the dependencies to.  If no <B>'-MF'</B> switch is given
the preprocessor sends the rules to the same place it would have sent
preprocessed output.
<BR><BR>
When used with the driver options <B>'-MD'</B> or <B>'-MMD'</B>,
<B>'-MF'</B> overrides the default dependency output file.
<BR><BR>
<DT><B>-MG</B>
<DD>In conjunction with an option such as <B>'-M'</B> requesting
dependency generation, <B>'-MG'</B> assumes missing header files are
generated files and adds them to the dependency list without raising
an error.  The dependency filename is taken directly from the
<CODE>#include</CODE> directive without prepending any path.  <B>'-MG'</B>
also suppresses preprocessed output, as a missing header file renders
this useless.
<BR><BR>
This feature is used in automatic updating of makefiles.
<BR><BR>
<DT><B>-MP</B>
<DD>This option instructs CPP to add a phony target for each dependency
other than the main file, causing each to depend on nothing.  These
dummy rules work around errors <CODE>make</CODE> gives if you remove header
files without updating the <CODE>Makefile</CODE> to match.
<BR><BR>
This is typical output:
<PRE>test.o: test.c test.h

test.h:
</PRE>
<DT><B>-MT <I>target</I></B>
<DD>Change the target of the rule emitted by dependency generation.  By
default CPP takes the name of the main input file, including any path,
deletes any file suffix such as <CODE>.c</CODE>, and appends the platform's
usual object suffix.  The result is the target.
<BR><BR>
An <B>'-MT'</B> option will set the target to be exactly the string you
specify.  If you want multiple targets, you can specify them as a single
argument to <B>'-MT'</B>, or use multiple <B>'-MT'</B> options.
<BR><BR>
For example, <B>'-MT '$(objpfx)foo.o''</B> might give
<PRE>$(objpfx)foo.o: foo.c
</PRE>
<DT><B>-MQ <I>target</I></B>
<DD>Same as <B>'-MT'</B>, but it quotes any characters which are special to
Make.
The default target is automatically quoted, as if it were given with
<B>'-MQ'</B>.
<BR><BR>
<DT><B>-MD</B>
<DD><B>'-MD'</B> is equivalent to <B>'-M -MF <I>file</I>'</B>, except that
<B>'-E'</B> is not implied.  The driver determines <I>file</I> based on
whether an <B>'-o'</B> option is given.  If it is, the driver uses its
argument but with a suffix of <CODE>.d</CODE>, otherwise it take the
basename of the input file and applies a <CODE>.d</CODE> suffix.
<BR><BR>
If <B>'-MD'</B> is used in conjunction with <B>'-E'</B>, any
<B>'-o'</B> switch is understood to specify the dependency output file, but
if used without <B>'-E'</B>, each <B>'-o'</B>
is understood to specify a target object file.
<BR><BR>
Since <B>'-E'</B> is not implied, <B>'-MD'</B> can be used to generate
a dependency output file as a side-effect of the compilation process.
<BR><BR>
<DT><B>-MMD</B>
<DD>Like <B>'-MD'</B> except mention only user header files, not system
-header files.
<BR><BR>
<DT><B>-x c</B>
<BR><B>-x c++</B>
<BR><B>-x objective-c</B>
<BR><B>-x assembler-with-cpp</B>
<DD>Specify the source language: C, C++, Objective-C, or assembly.  This has
nothing to do with standards conformance or extensions; it merely
selects which base syntax to expect.  If you give none of these options,
cpp will deduce the language from the extension of the source file:
<CODE>.c</CODE>, <CODE>.cc</CODE>, <CODE>.m</CODE>, or <CODE>.S</CODE>.  Some other common
extensions for C++ and assembly are also recognized.  If cpp does not
recognize the extension, it will treat the file as C; this is the most
generic mode.  Note that C++ and Objective-C are not supported in TIGCC.
<BR><BR>
<B>Note:</B> Previous versions of cpp accepted a <B>'-lang'</B> option
which selected both the language and the standards conformance level.
This option has been removed, because it conflicts with the <B>'-l'</B>
option.
<BR><BR>
<DT><B>-std=<I>standard</I></B>
<BR><B>-ansi</B>
<DD>Specify the standard to which the code should conform.  Currently CPP
knows about C and C++ standards; others may be added in the future
(although it will not be important for TIGCC).
<BR><BR>
<I>standard</I>
may be one of:
<BR><BR><DL>
<DT><B>iso9899:1990</B>
<BR><B>c89</B>
<DD>The ISO C standard from 1990.  <CODE>c89</CODE> is the customary shorthand for
this version of the standard.
<BR><BR>
The <B>'-ansi'</B> option is equivalent to <B>'-std=c89'</B>.
<BR><BR>
<DT><B>iso9899:199409</B>
<DD>The 1990 C standard, as amended in 1994.
<BR><BR>
<DT><B>iso9899:1999</B>
<BR><B>c99</B>
<BR><B>iso9899:199x</B>
<BR><B>c9x</B>
<DD>The revised ISO C standard, published in December 1999.  Before
publication, this was known as C9X.
<BR><BR>
<DT><B>gnu89</B>
<DD>The 1990 C standard plus GNU extensions.  This is the default.
<BR><BR>
<DT><B>gnu99</B>
<BR><B>gnu9x</B>
<DD>The 1999 C standard plus GNU extensions.
<BR><BR>
<DT><B>c++98</B>
<DD>The 1998 ISO C++ standard plus amendments.
<BR><BR>
<DT><B>gnu++98</B>
<DD>The same as <B>'-std=c++98'</B> plus GNU extensions.  This is the
default for C++ code.
</DL><BR>
<BR><BR>
<DT><B>-I-</B>
<DD>Split the include path.  Any directories specified with <B>'-I'</B>
options before <B>'-I-'</B> are searched only for headers requested with
<CODE>#include&nbsp;&quot;<I>file</I>&quot;</CODE>; they are not searched for
<CODE>#include&nbsp;&lt;<I>file</I>&gt;</CODE>.  If additional directories are
specified with <B>'-I'</B> options after the <B>'-I-'</B>, those
directories are searched for all <CODE>#include</CODE> directives.
<BR><BR>
In addition, <B>'-I-'</B> inhibits the use of the directory of the current
file directory as the first search directory for <CODE>#include
&quot;<I>file</I>&quot;</CODE>.
<BR><BR>
<DT><B>-nostdinc</B>
<DD>Do not search the standard system directories for header files.
Only the directories you have specified with <B>'-I'</B> options
(and the directory of the current file, if appropriate) are searched.
<BR><BR>
<DT><B>-nostdinc++</B>
<DD>Do not search for header files in the C++-specific standard directories,
but do still search the other standard directories (not applicable to TIGCC,
because it does not support C++).
<BR><BR>
<DT><B>-include <I>file</I></B>
<DD>Process <I>file</I> as if <CODE>#include&nbsp;&quot;file&quot;</CODE> appeared as the first
line of the primary source file.  However, the first directory searched
for <I>file</I> is the preprocessor's working directory <I>instead of</I>
the directory containing the main source file.  If not found there, it
is searched for in the remainder of the <CODE>#include&nbsp;&quot;...&quot;</CODE> search
chain as normal.
<BR><BR>
If multiple <B>'-include'</B> options are given, the files are included
in the order they appear on the command line.
<BR><BR>
<DT><B>-imacros <I>file</I></B>
<DD>Exactly like <B>'-include'</B>, except that any output produced by
scanning <I>file</I> is thrown away.  Macros it defines remain defined.
This allows you to acquire all the macros from a header without also
processing its declarations.
<BR><BR>
All files specified by <B>'-imacros'</B> are processed before all files
specified by <B>'-include'</B>.
<BR><BR>
<DT><B>-idirafter <I>dir</I></B>
<DD>Search <I>dir</I> for header files, but do it <I>after</I> all
directories specified with <B>'-I'</B> and the standard system directories
have been exhausted.  <I>dir</I> is treated as a system include directory.
<BR><BR>
<DT><B>-iprefix <I>prefix</I></B>
<DD>Specify <I>prefix</I> as the prefix for subsequent <B>'-iwithprefix'</B>
options.  If the prefix represents a directory, you should include the
final <CODE>/</CODE>.
<BR><BR>
<DT><B>-iwithprefix <I>dir</I></B>
<BR><B>-iwithprefixbefore <I>dir</I></B>
<DD>Append <I>dir</I> to the prefix specified previously with
<B>'-iprefix'</B>, and add the resulting directory to the include search
path.  <B>'-iwithprefixbefore'</B> puts it in the same place <B>'-I'</B>
would; <B>'-iwithprefix'</B> puts it where <B>'-idirafter'</B> would.
<BR><BR>
Use of these options is discouraged.
<BR><BR>
<DT><B>-isystem <I>dir</I></B>
<DD>Search <I>dir</I> for header files, after all directories specified by
<B>'-I'</B> but before the standard system directories.  Mark it
as a system directory, so that it gets the same special treatment as
is applied to the standard system directories.
See <A HREF="$$INFOLINK(cpp/SEC9a)">System Headers</A>.
<BR><BR>
<DT><B>-fpreprocessed</B>
<DD>Indicate to the preprocessor that the input file has already been
preprocessed.  This suppresses things like macro expansion, trigraph
conversion, escaped newline splicing, and processing of most directives.
The preprocessor still recognizes and removes comments, so that you can
pass a file preprocessed with <B>'-C'</B> to the compiler without
problems.  In this mode the integrated preprocessor is little more than
a tokenizer for the front ends.
<BR><BR>
<B>'-fpreprocessed'</B> is implicit if the input file has one of the
extensions <CODE>.i</CODE>, <CODE>.ii</CODE> or <CODE>.mi</CODE>.  These are the
extensions that GCC uses for preprocessed files created by
<B>'-save-temps'</B>.
<BR><BR>
<DT><B>-ftabstop=<I>width</I></B>
<DD>Set the distance between tab stops.  This helps the preprocessor report
correct column numbers in warnings or errors, even if tabs appear on the
line.  If the value is less than 1 or greater than 100, the option is
ignored.  The default is 8.
<BR><BR>
<DT><B>-fno-show-column</B>
<DD>Do not print column numbers in diagnostics.  This may be necessary if
diagnostics are being scanned by a program that does not understand the
column numbers, such as <CODE>dejagnu</CODE>.
<BR><BR>
<DT><B>-A <I>predicate</I>=<I>answer</I></B>
<DD>Make an assertion with the predicate <I>predicate</I> and answer
<I>answer</I>.  This form is preferred to the older form <B>'-A
<I>predicate</I>(<I>answer</I>)'</B>, which is still supported, because
it does not use shell special characters.
See <A HREF="$$INFOLINK(cpp/SEC39)">Assertions</A>.
<DT><B>-A -<I>predicate</I>=<I>answer</I></B>
<DD>Cancel an assertion with the predicate <I>predicate</I> and answer
<I>answer</I>.
<BR><BR>
<DT><B>-dCHARS</B>
<DD><I>CHARS</I> is a sequence of one or more of the following characters,
and must not be preceded by a space.  Other characters are interpreted
by the compiler proper, or reserved for future versions of GCC, and so
are silently ignored.  If you specify characters whose behavior
conflicts, the result is undefined.
<BR><BR><DL>
<DT><B>M</B>
<DD>Instead of the normal output, generate a list of <CODE>#define</CODE>
directives for all the macros defined during the execution of the
preprocessor, including predefined macros.  This gives you a way of
finding out what is predefined in your version of the preprocessor.
Assuming you have no file <CODE>foo.h</CODE>, the command
<PRE>touch foo.h; cpp -dM foo.h
</PRE>
will show all the predefined macros.
<BR><BR>
<DT><B>D</B>
<DD>Like <CODE>M</CODE> except in two respects: it does <I>not</I> include the
predefined macros, and it outputs <I>both</I> the <CODE>#define</CODE>
directives and the result of preprocessing.  Both kinds of output go to
the standard output file.
<BR><BR>
<DT><B>N</B>
<DD>Like <CODE>D</CODE>, but emit only the macro names, not their expansions.
<BR><BR>
<DT><B>I</B>
<DD>Output <CODE>#include</CODE> directives in addition to the result of
preprocessing.
</DL><BR>
<DT><B>-P</B>
<DD>Inhibit generation of linemarkers in the output from the preprocessor.
This might be useful when running the preprocessor on something that is
not C code, and will be sent to a program which might be confused by the
linemarkers.
See <A HREF="$$INFOLINK(cpp/SEC43)">Preprocessor Output</A>.
<BR><BR>
<DT><B>-C</B>
<DD>Do not discard comments.  All comments are passed through to the output
file, except for comments in processed directives, which are deleted
along with the directive.
<BR><BR>
You should be prepared for side effects when using <B>'-C'</B>; it
causes the preprocessor to treat comments as tokens in their own right.
For example, comments appearing at the start of what would be a
directive line have the effect of turning that line into an ordinary
source line, since the first token on the line is no longer a <CODE>#</CODE>.
<BR><BR>
<DT><B>-CC</B>
<DD>Do not discard comments, including during macro expansion.  This is
like <B>'-C'</B>, except that comments contained within macros are
also passed through to the output file where the macro is expanded.
<BR><BR>
In addition to the side-effects of the <B>'-C'</B> option, the
<B>'-CC'</B> option causes all C++-style comments inside a macro
to be converted to C-style comments.  This is to prevent later use
of that macro from inadvertently commenting out the remainder of
the source line.
<BR><BR>
The <B>'-CC'</B> option is generally used to support lint comments.
<BR><BR>
<DT><B>-gcc</B>
<DD>Define the macros __GNUC__, __GNUC_MINOR__ and
__GNUC_PATCHLEVEL__.  These are defined automatically when you use
<CODE>gcc&nbsp;-E</CODE>; you can turn them off in that case with
<B>'-no-gcc'</B>.
<BR><BR>
<DT><B>-traditional-cpp</B>
<DD>Try to imitate the behavior of old-fashioned C preprocessors, as
opposed to ISO C preprocessors.
See <A HREF="$$INFOLINK(cpp/SEC70)">Traditional Mode</A>.
<BR><BR>
<DT><B>-trigraphs</B>
<DD>Process trigraph sequences.
See <A HREF="$$INFOLINK(cpp/SEC3)">Initial processing</A>.
These are three-character sequences, all starting with <CODE>??</CODE>, that
are defined by ISO C to stand for single characters.  For example,
<CODE>??/</CODE> stands for <CODE>\</CODE>, so <CODE>'??/n'</CODE> is a character
constant for a newline.  By default, GCC ignores trigraphs, but in
standard-conforming modes it converts them.  See the <B>'-std'</B> and
<B>'-ansi'</B> options.
<BR><BR>
The nine trigraphs and their replacements are
<PRE>Trigraph:       ??(  ??)  ??&lt;  ??&gt;  ??=  ??/  ??'  ??!  ??-
Replacement:      [    ]    {    }    #    \    ^    |    ~
</PRE>
<DT><B>-remap</B>
<DD>Enable special code to work around file systems which only permit very
short file names, such as MS-DOS.
<BR><BR>
<DT><B>--help</B>
<BR><B>--target-help</B>
<DD>Print text describing all the command line options instead of
preprocessing anything.
<BR><BR>
<DT><B>-v</B>
<DD>Verbose mode.  Print out GNU CPP's version number at the beginning of
execution, and report the final form of the include path.
<BR><BR>
<DT><B>-H</B>
<DD>Print the name of each header file used, in addition to other normal
activities.  Each name is indented to show how deep in the
<CODE>#include</CODE> stack it is.
<BR><BR>
<DT><B>-version</B>
<BR><B>--version</B>
<DD>Print out GNU CPP's version number.  With one dash, proceed to
preprocess as normal.  With two dashes, exit immediately.
</DL>
