PATCH RFA: Support -Wmissing-declarations in C++

Gabriel Dos Reis gdr@cs.tamu.edu
Thu Dec 14 20:12:00 GMT 2006


Ian Lance Taylor <iant@google.com> writes:

| Currently -Wmissing-declarations only works for C.  But it makes just
| as much sense for C++ as it does for C.  This patch adds support for
| -Wmissing-declarations in C++.

I don't think it makes that much sense for C++, let alone as much sense.

In C++, if you don't have a declaration in scope, it is a hard error.
In C, the situation is different, which led to -Wmissing-declarations.

-Wmissing-declarations embodies C ways of viewing and programming,
that are counter-idiomatic in C++.

Furthermore, a function can be declared only once at class scope.  The
artificial dissymmetry that this switch will introduce for such a
fundamental notion as class in C++ is a strong hint that this switch
is best left for the C front-end.

-- Gaby



More information about the Gcc-patches mailing list