gcc function call semantics for mismatch signature in caller/callee
I discovered something strange in gcc and hoping to get some input whether its a feature or quirk.
Essentially I have a function defined in func.c asvoid f(int a, int b, FILE* f)
{
...
...
}
The开发者_如何学Pythonre is no corresponding header file. But gcc doesn't give any warning when I call f(a,b) and gdb shows me that f is called with three parameters? Why is this the case?. What is the semantics for filling up the third argument.
If f()
doesn't have a declaration anywhere and is not defined in the current compilation unit, the compiler assumes that f()
returns int
and can take any number of arguments.
I know this is odd, but in the old days this was possibly a way to reduce the number of header files that have to be included, and hence faster compilation.
精彩评论