When my program consists of two files:
main.c
#include
int main(void) {
printf(\"%lf\\n\",f());
return 0;
}
>
C will assume a function has the prototype int func(); unless you have told it otherwise.(Note that in C int func(); and int func(void); are different things)
In your second case, you do a call to f()
for which the compiler hasn't seen any prototype, so it assumes it is int f();
. Later on it sees your definition for f()
which has a different prototype - and issues an error.
This doesn't happen in the 1. case, as they're in different compilation units.