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 wrote:
> There is nothing explicitly wrong with struct foo { } in either GNU C
> or C++. There could be a problem, if C and C++ are later linked
> together, but we have no way to detect that at compile time.
>
> Using extern "C", however, is a clear statement that you are attempting
> to do something which will not work.
I think that's a good point. Obviously, I can think of cases where that
wouldn't be true, but warnings are heuristics, and heuristically, I
think you're right.
(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.)
Still, I think the warning itself is OK. However, the patch is
incomplete, because it is missing invoke.texi documentation. (It would
sure be nice to auto-generate that from texinfo fragments in .opt files,
but...)
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713