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


On Wed, May 17, 2006 at 09:49:16AM -0700, Andrew Pinski wrote:
> 
> If you are going to warn about very valid and well defined C++ code,  
> that is just crazy.

There are many warnings already for valid constructs which have a
high probability of being an error, such as "if (a=b)", so what's the
problem here?

As has been pointed out, the empty structure syntax is valid in both
g++ and gcc, and by itself is not likely to be an error.  But the
extern-C construct indicates that the following C++ code will be used
with C, and in my opinion issuing a warning for places that might not
work is a very good idea, especially if the user asks for it.

In other words, it's a (potential) problem only when code is used with
both C and C++.  If there was a C construct that hinted that "this code
is going to be used with C++," then warning on the C side when that
construct was used would be appropriate.  As it is, only C++ knows about
this intersection, so that's a good place for the warning.

  Oleg


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