3 ms·
> this is an error because the compiler treats each .c file separately, so when it’s compiling main.c, it isn’t looking at f.c, so it has no way to know the fun
by clarry 6y ago
> this is an error because the compiler treats each .c file separately, so when it’s compiling main.c, it isn’t looking at f.c, so it has no way to know the function f exists.
But it's not an error and the compiler does not need to know the function exists. If there's no declaration, then the function's type is implicit and simply assumed to exist.
If the function doesn't actually exist, then it's your linker that will complain.
- umanwizard 6y agoYou're right (even with `gcc --std=c99 --pedantic`, which surprised me!) I should have said that the compiler won't be able to type-check the arguments and return value.