annotate gcc/doc/cppwarnopts.texi @ 145:1830386684a0

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