How do I get missing prototype warnings from g++?
c++, compiler-warnings, g++, warnings
Solution
Did you try -Wmissing-declarations? That seems to work for g++ and detect the error case you describe. I'm not sure which version they added it in, but it works for me in 4.3.3.
Problem
I currently have a project that uses g++ to compile it's code. I'm in the process of cleaning up the code, and I'd like to ensure that all functions have prototypes, to ensure things like const char * are correctly handled. Unfortunately, g++ complains when I try to specify -Wmissing-prototypes: ``` g++ -Wmissing-prototypes -Wall -Werror -c foo.cpp cc1plus: warning: command line option "-Wmissing-prototypes" is valid for Ada/C/ObjC but not for C++ ``` Can someone tell me: 1) Why does gcc this isn't valid? Is this a bug in gcc? 2) Is there a way to turn on this warning? EDIT: Here's a cut and paste example: ``` cat > foo.cpp <<EOF void myfunc(int arg1, int arg2) { /* do stuff with arg1, arg2 */ } EOF g++ -Wmissing-prototypes -c foo.cpp # complains about not valid g++ -c foo.cpp # no warnings # Compile in C mode, warning appears as expected: g++ -x c -Wmissing-prototypes -c foo.cpp ```