在用error: ‘SIG_BLOCK’ undeclared编译时,我会得到这段代码的错误消息-ansi。
sigprocmask(SIG_BLOCK, &my_sig, NULL);
我忘了对某些头文件说清楚了吗?这些是我的包括
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <stdarg.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>发布于 2015-05-17 06:34:54
您需要告诉编译器您希望定义SIG_BLOCK。
来自man sigaction
glibc的特性测试宏要求(请参阅宏(7)): σ-掩码():_POSIX_C_SOURCE >= 1\x{e 010}\x{e76f}\x{e76f}\x{e76f}
所以你可能想通过这个选项
-D_POSIX_SOURCE或
-D_POSIX_C_SOURCE=1比如gcc
另外,您可以将这些“请求”作为预处理指令放在源的顶部:
#define _POSIX_SOURCE
... /* other includes */
#include <signal.h>或
#define _POSIX_C_SOURCE 1
... /* other includes */
#include <signal.h>https://stackoverflow.com/questions/30283507
复制相似问题