C is much less strict than C ++ in some respects.
The signature of the f() function in C ++ means a function with no arguments, and the appropriate compiler must provide this. In C, on the contrary, the behavior is not defined, and compilers do not need to diagnose if a function is called with arguments, even if it was defined without parameters. In practice, modern compilers should at least warn about inappropriate use.
Also, in function prototype declarations (without definition) in C, empty brackets mean that parameters are undefined. Subsequently, it can be defined with any number of arguments.
To prevent this, use the following ISO / IEC 9899 6.7.6.3/10 prototype :
int f(void)
source share