【问题标题】:handling warning: implicit declaration of function ‘sigignore’处理警告:函数‘sigignore’的隐式声明
【发布时间】:2016-04-18 14:06:07
【问题描述】:

这是我的代码:

#include <sys/types.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <time.h> 
#include <sys/time.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>

int main(int argc, char** argv) {

sigignore(SIGTERM);
return 0;
}

为什么我会收到以下警告以及如何删除它?

函数‘sigignore’的隐式声明 [-Wimplicit-function-declaration] sigignore(SIGTERM);

程序必须像这样编译:gcc -o foo.o foo.c

谢谢

【问题讨论】:

    标签: c compilation posix compiler-warnings


    【解决方案1】:

    Man sigignore 告诉你使用 #define _XOPEN_SOURCE 500 来启用 sigignore。更多关于 X/Open 的信息可以在here

    【讨论】:

    【解决方案2】:

    您要调用的函数在 15 年前已被标记为过时。阻止人们使用这些函数(实际上不会破坏程序)的常规方法是将函数的实现留在标准库中,但从头文件中删除声明(或至少使其难以启用)。

    使用sigactionsigprocmask(取决于您实际想要完成的任务)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      相关资源
      最近更新 更多