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

[Bug c++/50134] -Wmissing-prototypes doesn't work for C++


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.


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