warning: implicit declaration of function 'getpid' 解决方法
在C程序中使用getpid()获取进程识别码时,可能会出现warning: implicit declaration of function 'getpid'; did you mean 'getenv'? [-Wimplicit-function-declaration]这样的警告信息;
警告信息并不会影响程序编译;
解决方法
在代码中添加以下文件头:
#include <unistd.h>
忽略警告信息
你可以在编译程序时添加-w
来忽略警告信息;
例:
gcc -w test.c