[Bug c++/13687] New: -Wmissing-prototypes should not be ignored for C++
t dot schutter at att dot net
gcc-bugzilla@gcc.gnu.org
Wed Jan 14 22:22:00 GMT 2004
Currently, -Wmissing-prototypes is ignored when compiling C++ code. I believe
that this is because it is assumed that missing prototypes are errors when
compiling C++ code. This is true, except when using the extern "C" { }
construct. When using this construct, you should be able to get "no previous
prototype" warnings.
This problem is most evident when using the JNI native interface which uses the
extern "C" { } construct. Prototype/function mismatches are not found until
runtime.
The following example shows the problem:
/*
Compiling as C gives a warning:
$ gcc -c -Wmissing-prototypes gccbug.c
gccbug.c:19: warning: no previous prototype for `bar'
$
Compiling as C++ gives no warning:
$ g++ -c -Wmissing-prototypes gccbug.c
$
*/
#ifdef __cplusplus
extern "C" {
#endif
void foo(void);
void foo(void) { }
void bar(void) { }
#ifdef __cplusplus
}
#endif
--
Summary: -Wmissing-prototypes should not be ignored for C++
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: t dot schutter at att dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13687
More information about the Gcc-bugs
mailing list