Ben Pfaff wrote: > > - There is no reason for GCC to warn about foo(). > > Probably Eric is using -Wstrict-prototypes: > > `-Wstrict-prototypes (C and Objective-C only)' > Warn if a function is declared or defined without specifying the > argument types. (An old-style function definition is permitted > without a warning if preceded by a declaration which specifies the > argument types.) > > -Wstrict-prototypes is useful for finding foo()-style > declarations (especially in header files) to remind the > programmer to change them to foo(void) prototypes, so that > callers cannot inadvertently invoke them with one or more > arguments.
I agree with the usefulness of this warning for function *declarations*. But for function *definitions* it is not useful to warn about int foo(void) { ... } because when the caller inadvertently provides the wrong number of arguments, a compilation error results anyway. This GCC warning option is broken. It warns about code for which there is no reason to warn about. Bruno