This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug preprocessor/16358] -Wno-system-headers hides warning caused by user header vs system header conflict
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Apr 2016 16:27:00 +0000
- Subject: [Bug preprocessor/16358] -Wno-system-headers hides warning caused by user header vs system header conflict
- Auto-submitted: auto-generated
- References: <bug-16358-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16358
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
--- Comment #10 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to niva from comment #9)
-Werror turns the warning GCC issues for a macro redefinition into an error. A
part of the problem is that warnings in system headers are suppressed by
default, without -Wsystem-headers, so -Werror alone doesn't help.
What is also missing, though, is a mechanism/option to silence the macro
redefinition warning without also suppressing all other warnings (i.e., an
option other that -w).
For example, there is no way to suppress the warning in the example below
without also suppressing the -Wcpp warning. In contrast to GCC, Clang provides
the -Wmacro-redefined option that makes it possible to control just the macro
redefinition warning.
Providing the same feature in GCC might help resolve this problem by enabling
warnings for macro redefinitions in user headers without also enabling all
other warnings in them.
$ cat t.c && gcc -S t.c
#define A 1
#define A 2
#warning foo
t.c:2:0: warning: "A" redefined
#define A 2
t.c:1:0: note: this is the location of the previous definition
#define A 1
t.c:3:2: warning: #warning foo [-Wcpp]
#warning foo
^~~~~~~