This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug preprocessor/16358] -Wno-system-headers hides warning caused by user header vs system header conflict


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
  ^~~~~~~

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]