warning: implicit declaration of function 'kill'

社会主义新天地 提交于 2019-12-21 03:49:44

问题


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


来源:https://stackoverflow.com/questions/9994530/warning-implicit-declaration-of-function-kill

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!