Number of arguments mismatch in function call
Sulabh Nangalia
sulabh.nangalia@gmail.com
Thu May 20 16:04:00 GMT 2010
Hi,
I have a question with function definition.
Please consider following 3 different forms
of writing a same test example:
1.
static int foo(i, j)
int i;
float j;
{
return i;
}
int main()
{
return foo(1); // Passing less arguments
}
2.
static int foo(int, float);
static int foo(i, j)
int i;
float j;
{
return i;
}
int main()
{
return foo(1); // Passing less arguments
}
test.c: In function 'main':
test.c:10: error: too few arguments to function 'foo'
3.
static int foo(int i, float j)
{
return i;
}
int main()
{
return foo(1); // Passing less arguments
}
I am using gcc version 4.1.2 to compile all the 3 variations as:
% gcc test.c
The first one compiles fine.
While the 2nd & 3rd give following error:
test.c: In function 'main':
test.c:7: error: too few arguments to function 'foo'
Can someone please explain if this is a bug of gcc
or a desired behavior and why?
--
Regards,
Sulabh Nangalia
More information about the Gcc-help
mailing list