What more could you want?
warning: incompatible implicit declaration of built-in function ‘strlen’
This is an error presented by the GNU Compiler Collection (which I still like to call the GNU C Compiler) when compiling a piece of code that calls to a function in the <string.h> header file if it cannot find the function.
Typically, this is caused by a call to the strlen function when the <string.h> header has not been included.
$ grep ‘#include’ whiteout.c
#include <stdio.h>
$ gcc -o ../whiteout whiteout.c
whiteout.c: In function ‘trim’:
whiteout.c:49: warning: incompatible implicit declaration of built-in function ‘strlen’
whiteout.c: In function ‘add’:
whiteout.c:64: warning: incompatible implicit declaration of built-in function ‘strlen’$ grep ‘#include’ whiteout.c
#include <stdio.h>
#include <string.h>
$ gcc -o ../whiteout whiteout.c
$
As you can see, simply placing the statement ‘#include <string.h>’ into your includes section of your code will alleviate the issue.
/cs
| Print article | This entry was posted by chuck on March 2, 2008 at 2:31 pm, and is filed under Code. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 2 years ago
Thanks very much for this solution.. It is so useful for me. Sometimes, I didn’t see some errors because many warnings appears!.
about 2 years ago
awesome! dint think the soln was so simple. battered my head about it for quite some time
thanks!
about 1 year ago
thank you very much.. that’s simple but stdio.h very usefull for strlen
about 1 year ago
I downloaded C code directly from a textbook website, and it pitched this error for strlen and exit. Fixing my includes solved the issue, Thanks.