warning: incompatible implicit declaration of built-in function ‘xyz’
In the case of some programs, these errors are normal and should not be fixed.
I get these error messages when compiling the program phrap (for example). This program happens to contain code that modifies or replaces some built in functions, and when I include the appropriate header files to fix the warnings, GCC instead generates a bunch of errors. So fixing the warnings effectively breaks the build.
If you got the source as part of a distribution that should compile normally, the errors might be normal. Consult the documentation to be sure.
I'm getting a number of these warnings when compiling a few binaries:
warning: incompatible implicit declaration of built-in function ‘strcpy’ warning: incompatible implicit declaration of built-in function ‘strlen’ warning: incompatible implicit declaration of built-in function ‘exit’
To try to resolve this, I have added
at the top of the C files associated with this warning, in addition to compiling with the following flags:
CFLAGS = -fno-builtin-exit -fno-builtin-strcat -fno-builtin-strncat -fno-builtin-strcpy -fno-builtin-strlen -fno-builtin-calloc
I am using GCC 4.1.2:
$ gcc --version gcc (GCC) 4.1.2 20080704
What should I do to resolve these warnings?
I met these warnings on
mempcpy function. Man page says this function is a GNU extension and synopsis shows:
#define _GNU_SOURCE #include <string.h>
#define is added to my source before the
#include, declarations for the GNU extensions are made visible and warnings disappear.