I faced a similar problem in my (big) project.
//# include <string.h> // not included
void foo(char * str, const char * delim)
char * tok = strtok(str, delim);
// warning ^ "assignement makes pointer from integer without a cast"
undefined reference to function 'strtok'
While linking your binary, unless explicitly mentioned, your binary is linked with the default C standard library (
glibc, for example) anyways, where the function is defined.
So, when you miss the header file containing the declaration, you end up with the warning (in case the function prototype has a mismatchnote) but during linking time, due to the presence of the default C library, the program is successfully linked anyway.
FWIW, according to
C11, support for implicit function declaration has been dropped but most compilers support the bad behavior to keep the backward compatibility for the legacy code.
Implicit function declaration: Earlier, (before C99, AFAIK), the standard did not mandate for a function to have the forward declaration. In case, a function would have been used without a forward declaration, it was assumed to return
int and accept any number of incoming parameters.