This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50134] -Wmissing-prototypes doesn't work for C++
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 30 Sep 2011 14:16:40 +0000
- Subject: [Bug c++/50134] -Wmissing-prototypes doesn't work for C++
- Auto-submitted: auto-generated
- References: <bug-50134-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50134
--- Comment #6 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-09-30 14:16:40 UTC ---
On Fri, 30 Sep 2011, redi at gcc dot gnu.org wrote:
> I'm not sure what "Do so even if the definition itself provides a prototype."
> means in the context of C++.
That's simple enough: it's a style warning: a global function should be
declared in a header, so warn for
int
f (void)
{
return 0;
}
if there was no previous declaration for f. (For C++, the definition and
any previous declaration will always provide a prototype.)
As Ian said in <http://gcc.gnu.org/ml/gcc/2011-08/msg00366.html>, for C++
the two options reduce to the same thing because no non-prototype
declarations or definitions exist. For C,
int f();
int f(void) { return 0; }
gets a warning with -Wmissing-prototypes but not -Wmissing-declarations,
because "int f();" is a non-prototype declaration in C.