This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions
- From: "eggert at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 28 Jul 2012 13:47:28 +0000
- Subject: [Bug c/54113] New: -Wmissing-prototypes cries wolf for C99 inline functions
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113
Bug #: 54113
Summary: -Wmissing-prototypes cries wolf for C99 inline
functions
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: eggert@gnu.org
-Wmissing-prototypes produces false alarms for C99-style
inline functions. Here's a simple example, taken from
<http://www.drdobbs.com/the-new-c-inline-functions/184401540>.
Suppose foo.h contains this:
inline float square(float x) {return x*x;}
inline float cube(float x) {return x*x*x;}
and foo.c contains this:
#include "foo.h"
extern float square(float x);
extern float cube(float x);
Then the command:
gcc -c -Wmissing-prototypes foo.c
outputs:
In file included from foo.c:1:0:
foo.h:1:14: warning: no previous prototype for 'square'
[-Wmissing-prototypes]
foo.h:2:14: warning: no previous prototype for 'cube' [-Wmissing-prototypes]
The diagnostics should not be output, as this is the normal
way to use inline functions in C.
The simplest way to work around the problem is to avoid
the use of -Wmissing-prototypes, but that disables the
diagnostic for non-inline functions, where it's useful.
To fix this, I suggest that the diagnostic be suppressed
for inline functions, at least for C99 mode.