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