【发布时间】:2012-11-17 01:55:25
【问题描述】:
如果我用 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’
【问题讨论】:
-
它需要
_GNU_SOURCE才能使用 C99 标准编译它。请改用gcc -std=c99 -D_GNU_SOURCE blah.c -o blah。 -
@user9000 那为什么还要麻烦
-std=c99呢?只需使用gcc -std=gnu99即可完成。 -
@melpomene 这与它有什么关系?
_GNU_SOURCE提供了一些 GNU 扩展。 -
抱歉没注意到你说的是gnu,还以为是89;P