This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13687] New: -Wmissing-prototypes should not be ignored for C++
- From: "t dot schutter at att dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jan 2004 22:21:59 -0000
- Subject: [Bug c++/13687] New: -Wmissing-prototypes should not be ignored for C++
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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