Here is a warning from me and many people on the Internet, see when running gcc in C ++ code:
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
The warning text is very clear: "C ++" is not included in the [Ada / C / ObjC] set, so I have no questions about why gcc gives this warning when compiling C ++ code. (FYI is the reason why we have this flag, despite the presence of C ++ code, because it is mainly C code, we chose a strict (high level) list of warnings, but we added some C ++ code.
My question is: why is this warning not valid for C ++?
The gcc documentation for the warning option from http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Warning-Options.html :
-Wstrict-prototypes (C and Objective-C only) Warn if a function is declared or defined without specifying argument types. (An definition of an old-style function is permitted without warning if preceded by an declaration defining argument types.)
Now I just know that I am forgetting something obvious about C ++, but does not C ++ also require specifying argument types for functions in the prototype? True, these function prototypes are often found in class declarations because functions are often member functions, but aren't prototypes required? Or even if it's just good practice, why not gcc offer this option? Or, if not, a parallel option for C ++?
source share