[英]why am i not able to declare sigset_t with std=c99?
如果我用std = c99編譯下面的程序,我得到一個錯誤,但程序編譯沒有c99標志罰款。 為什么?
#include <signal.h>
void x()
{
sigset_t dd;
}
int main(void)
{
x();
return 0;
}
jim@cola temp]$ gcc -std=c99 blah.c -o blah
blah.c: In function ‘x’:
blah.c:9: error: ‘sigset_t’ undeclared (first use in this function)
blah.c:9: error: (Each undeclared identifier is reported only once
blah.c:9: error: for each function it appears in.)
blah.c:9: error: expected ‘;’ before ‘dd’
因為sigset_t
不是標准C中<signal.h>
一部分,並且您要求與-std=c99
具有嚴格的標准兼容性。 也就是說,嚴格標准的C程序可以:
#include <signal.h>
int sigset_t;
int main(void) { return 0; }
期待它的運作。
sigset_t
不符合C99標准,但它在POSIX中可用。 您可以定義_POSIX_SOURCE
或_POSIX_C_SOURCE
以使sigset_t
可用。
這是定義:
#define _NSIG 64
#define _NSIG_BPW 32
#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
typedef unsigned long old_sigset_t; /* at least 32 bits */
typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.