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
Daniel Jacobowitz <drow@false.org> writes:
| On Wed, May 17, 2006 at 06:15:25PM +0200, Gabriel Dos Reis wrote:
| > As has been pointed out; what you want is to warn for this construct
| > not just for C++, but also for GNU C. I suggest you drop the "-c" in
| > "empty-c-struct".
|
| For the record, if you meant my explanation, that's not at all what I
| was trying to point out.
OK, please explain it to me again.
>From my perspective
extern "C" { struct S { }; }
is not turning the C++ compiler to define a C program. So, the issue
here is whether it would cause a portability problem with C programs
-- this is a very rare case of C/c++ compatibility. It also appears
that the definition of S is permitted in GNU C with completely a
different meaning. Consequnently, the warning -- if we must have a
warning -- should not be confined to the C++ front-end...
Richard G. made a comment that I find quite appropriate. If we are
going down this road, then we should start warning C codes.
Especially, sizeof ('a') and such. The arguments for this patch hold
verbatim. Hence, the question is what kind of consistency are we
after?
I don't agree that it should be in -Wall though.
-- Gaby