1*0bfacb9bSmrg@c Copyright (C) 1999-2020 Free Software Foundation, Inc.
2ac8e35e1Smrg@c This is part of the CPP and GCC manuals.
3ac8e35e1Smrg@c For copying conditions, see the file gcc.texi.
4ac8e35e1Smrg
5ac8e35e1Smrg@c ---------------------------------------------------------------------
6ac8e35e1Smrg@c Options affecting preprocessor warnings
7ac8e35e1Smrg@c ---------------------------------------------------------------------
8ac8e35e1Smrg
9ac8e35e1Smrg@c If this file is included with the flag ``cppmanual'' set, it is
10ac8e35e1Smrg@c formatted for inclusion in the CPP manual; otherwise the main GCC manual.
11ac8e35e1Smrg
12ac8e35e1Smrg@item -Wcomment
13ac8e35e1Smrg@itemx -Wcomments
14ac8e35e1Smrg@opindex Wcomment
15ac8e35e1Smrg@opindex Wcomments
16ac8e35e1SmrgWarn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
17ac8e35e1Smrgcomment, or whenever a backslash-newline appears in a @samp{//} comment.
18ac8e35e1SmrgThis warning is enabled by @option{-Wall}.
19ac8e35e1Smrg
20ac8e35e1Smrg@item -Wtrigraphs
21ac8e35e1Smrg@opindex Wtrigraphs
22ac8e35e1Smrg@anchor{Wtrigraphs}
23ac8e35e1SmrgWarn if any trigraphs are encountered that might change the meaning of
24ac8e35e1Smrgthe program.  Trigraphs within comments are not warned about,
25ac8e35e1Smrgexcept those that would form escaped newlines.
26ac8e35e1Smrg
27ac8e35e1SmrgThis option is implied by @option{-Wall}.  If @option{-Wall} is not
28ac8e35e1Smrggiven, this option is still enabled unless trigraphs are enabled.  To
29ac8e35e1Smrgget trigraph conversion without warnings, but get the other
30ac8e35e1Smrg@option{-Wall} warnings, use @samp{-trigraphs -Wall -Wno-trigraphs}.
31ac8e35e1Smrg
32ac8e35e1Smrg@item -Wundef
33ac8e35e1Smrg@opindex Wundef
34ac8e35e1Smrg@opindex Wno-undef
35ac8e35e1SmrgWarn if an undefined identifier is evaluated in an @code{#if} directive.
36ac8e35e1SmrgSuch identifiers are replaced with zero.
37ac8e35e1Smrg
38ac8e35e1Smrg@item -Wexpansion-to-defined
39ac8e35e1Smrg@opindex Wexpansion-to-defined
40ac8e35e1SmrgWarn whenever @samp{defined} is encountered in the expansion of a macro
41ac8e35e1Smrg(including the case where the macro is expanded by an @samp{#if} directive).
42ac8e35e1SmrgSuch usage is not portable.
43ac8e35e1SmrgThis warning is also enabled by @option{-Wpedantic} and @option{-Wextra}.
44ac8e35e1Smrg
45ac8e35e1Smrg@item -Wunused-macros
46ac8e35e1Smrg@opindex Wunused-macros
47ac8e35e1SmrgWarn about macros defined in the main file that are unused.  A macro
48ac8e35e1Smrgis @dfn{used} if it is expanded or tested for existence at least once.
49ac8e35e1SmrgThe preprocessor also warns if the macro has not been used at the
50ac8e35e1Smrgtime it is redefined or undefined.
51ac8e35e1Smrg
52ac8e35e1SmrgBuilt-in macros, macros defined on the command line, and macros
53ac8e35e1Smrgdefined in include files are not warned about.
54ac8e35e1Smrg
55ac8e35e1Smrg@emph{Note:} If a macro is actually used, but only used in skipped
56ac8e35e1Smrgconditional blocks, then the preprocessor reports it as unused.  To avoid the
57ac8e35e1Smrgwarning in such a case, you might improve the scope of the macro's
58ac8e35e1Smrgdefinition by, for example, moving it into the first skipped block.
59ac8e35e1SmrgAlternatively, you could provide a dummy use with something like:
60ac8e35e1Smrg
61ac8e35e1Smrg@smallexample
62ac8e35e1Smrg#if defined the_macro_causing_the_warning
63ac8e35e1Smrg#endif
64ac8e35e1Smrg@end smallexample
65ac8e35e1Smrg
66ac8e35e1Smrg@item -Wno-endif-labels
67ac8e35e1Smrg@opindex Wno-endif-labels
68ac8e35e1Smrg@opindex Wendif-labels
69ac8e35e1SmrgDo not warn whenever an @code{#else} or an @code{#endif} are followed by text.
70ac8e35e1SmrgThis sometimes happens in older programs with code of the form
71ac8e35e1Smrg
72ac8e35e1Smrg@smallexample
73ac8e35e1Smrg#if FOO
74ac8e35e1Smrg@dots{}
75ac8e35e1Smrg#else FOO
76ac8e35e1Smrg@dots{}
77ac8e35e1Smrg#endif FOO
78ac8e35e1Smrg@end smallexample
79ac8e35e1Smrg
80ac8e35e1Smrg@noindent
81ac8e35e1SmrgThe second and third @code{FOO} should be in comments.
82ac8e35e1SmrgThis warning is on by default.
83