So I was recently reading a bit on Hacker News about function pointers and was enlightened to the fact that void foo()
and void foo(void)
are NOT equivalent prototypes. So, I set about ensuring that this is actually true:
int foo()
{
return 0;
}
int main()
{
return foo(1,2,3,4);
}
Sure enough, this code compiles without even so much as a warning.. where as this code will throw an error:
int foo(void)
{
return 0;
}
int main()
{
return foo(1,2,3,4);
}
This seems very error prone. I also thought that ...
for "any amount of arguments", such as in printf
's signature
int printf ( const char * format, ... );
Was this also true in C89 or K&R? Can anyone give insight into the use case for this "feature"?