What are the implications of having an "implicit declaration of function" warning in C?

Posted by SiegeX on Stack Overflow See other posts from Stack Overflow or by SiegeX
Published on 2010-04-22T04:58:36Z Indexed on 2010/04/22 5:03 UTC
Read the original article Hit count: 270

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about c

    Related posts about function