warning: implicit declaration of function 'kil

2019-03-26 00:24发布

问题:

I am making these inclusions:

#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

But still getting this warning.

回答1:

You are probably passing the "-ansi -Wall" switches to the gcc compiler. You can remove "-ansi" if you don't need it, otherwise try to set the proper feature define macro.

Something like:

#define _POSIX_SOURCE
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>


回答2:

You can also define it on the compile time by adding this flag with gcc.

-D_POSIX_C_SOURCE

ex:

-g -D_POSIX_C_SOURCE -Wall -std=c99


标签: c kill