[cfe-dev] gcc compatibility: error: number of arguments doesn't match prototype

Joerg Sonnenberger joerg at britannica.bec.de
Fri Apr 6 13:20:21 PDT 2012

On Fri, Apr 06, 2012 at 04:35:39PM +0800, Afriza N. Arief wrote:
> The way gcc handles the number of parameters is strange:
> (1)
> void abc(int a);
> void abc() {}
> int main() {}
> => gcc produces:
> af.c: In function ‘abc’:
> af.c:2:1: error: number of arguments doesn’t match prototype
> af.c:1:6: error: prototype declaration
> => clang compiles successfully. the attached patch changes this to a warning

Please keep in mind that for C, the second mode does not specify a
function with 0 arguments. It's K&R style for a variadic function.
As such, it is incorrect to talk about "number of arguments".

> (2)
> void abc();
> void abc(int a) {}
> int main() {}
> => gcc compiles successfully!
> => clang compiles successfully

This is just as bogus and should create at least a warning.


More information about the cfe-dev mailing list