]>
Commit | Line | Data |
---|---|---|
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 | |
16 | Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*} | |
17 | comment, or whenever a backslash-newline appears in a @samp{//} comment. | |
18 | This warning is enabled by @option{-Wall}. | |
19 | ||
20 | @item -Wtrigraphs | |
21 | @opindex Wtrigraphs | |
22 | @anchor{Wtrigraphs} | |
23 | Warn if any trigraphs are encountered that might change the meaning of | |
24 | the program. Trigraphs within comments are not warned about, | |
25 | except those that would form escaped newlines. | |
26 | ||
27 | This option is implied by @option{-Wall}. If @option{-Wall} is not | |
28 | given, this option is still enabled unless trigraphs are enabled. To | |
29 | get 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 | |
35 | Warn if an undefined identifier is evaluated in an @code{#if} directive. | |
36 | Such identifiers are replaced with zero. | |
37 | ||
38 | @item -Wexpansion-to-defined | |
39 | @opindex Wexpansion-to-defined | |
40 | Warn 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). | |
42 | Such usage is not portable. | |
43 | This warning is also enabled by @option{-Wpedantic} and @option{-Wextra}. | |
44 | ||
45 | @item -Wunused-macros | |
46 | @opindex Wunused-macros | |
47 | Warn about macros defined in the main file that are unused. A macro | |
48 | is @dfn{used} if it is expanded or tested for existence at least once. | |
ec85a978 | 49 | The preprocessor also warns if the macro has not been used at the |
c05169aa SL |
50 | time it is redefined or undefined. |
51 | ||
52 | Built-in macros, macros defined on the command line, and macros | |
53 | defined in include files are not warned about. | |
54 | ||
55 | @emph{Note:} If a macro is actually used, but only used in skipped | |
ec85a978 | 56 | conditional blocks, then the preprocessor reports it as unused. To avoid the |
c05169aa SL |
57 | warning in such a case, you might improve the scope of the macro's |
58 | definition by, for example, moving it into the first skipped block. | |
59 | Alternatively, 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 | |
69 | Do not warn whenever an @code{#else} or an @code{#endif} are followed by text. | |
ec85a978 | 70 | This 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 |
81 | The second and third @code{FOO} should be in comments. |
82 | This warning is on by default. |