This is the mail archive of the gcc-patches@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]

Re: [C++ PATCH] warning about empty extern "C" structures


Roman Kononov <kononov@dls.net> writes:

| On 05/17/2006 11:40, Gabriel Dos Reis wrote:
| > 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.
| Such warning in C code would be pointless. Because this is valid GCC
| code.

By that token, the warning is also pointless in g++.

| This is valid G++ code too. But extern "C" is an intent to make
| a C++ interface to the C code. And the interface is broken, about
| which a warning is desired.

This is an INVALID C construct.  It is only permited in GNU C which
carefully chosed to depart from the C++ semantics. Consequently, the
brokneness, if you're after that is in GNU C.  You have convinced me
that that is where (the C frone-end) you have to put the  warning.
Please do revise the patch. 

-- Gaby


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