This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] warning about empty extern "C" structures
Mark Mitchell <mark@codesourcery.com> writes:
| Gabriel Dos Reis wrote:
| > Mark Mitchell <mark@codesourcery.com> writes:
| >
| > | (However, we normally don't warn in system headers, and I'd guess that's
| > | where we're more likely to run into empty C structs, so the warning
| > | might not be that useful.)
| >
| > unless -Wsystem-headers.
| >
| > I think the warning should be in the C front-end.
|
| I thought the C front-end already had a mode where it warned about
| non-standard C: -pedantic.
People for some reasons don't want that for this particular construct
because it is not fine grained enough.
| I wouldn't mind if it had another warning for this case, but clearly
| this warning should at least be in the C++ front-end, since the failure
| mode is using C headers from C++. There's no way in a C program to
| indicate if you want your header to be used from C++, whereas there is a
| way for a C++ program to say that it's using something from C code:
| extern "C".
|
| If you want to add a warning to the C front end, using the same option,
| I wouldn't object.
this specific warning really belongs to the C front-end because it is
specifically problematic there. The problem becomes compounded when
it is used within C++ programs, but linked with C parts. So, yes, I
agree it would be nice it be in both languages, but I strongly object
to it being being a g++ primary option, and "generously" extended to C.
It must be a C option -- warning for empty structs as members, array
of empty structs -- that extends to C++. The patch should be revised
in that direction.
-- Gaby