What are the implications of having an "implicit declaration of function" warning in C?
- by SiegeX
As the question states, what exactly are the implications of having the 'implicit declaration of function' warning? We just cranked up the warning flags on gcc and found quite a few instances of these warnings and I'm curious what type of problems this may have caused prior to fixing them?
Also, why is this a warning and not an error. How is gcc even able to successfully link this executable? As you can see in the example below, the executable functions as expected.
Take the following two files for example:
file1.c
#include <stdio.h>
int main(void)
{
funcA();
return 0;
}
file2.c
#include <stdio.h>
void funcA(void)
{
puts("hello world");
}
Compile & Output
$ gcc -Wall -Wextra -c file1.c file2.c
file1.c: In function 'main':
file1.c:3: warning: implicit declaration of function 'funcA'
$ gcc -Wall -Wextra file1.o file2.o -o test.exe
$ ./test.exe
hello world