If i compile the below program with std=c99, i get an error, but the program compiles fine without the c99 flag. Why?
JavaScript
x
#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’
Advertisement
Answer
Because sigset_t
is not part of <signal.h>
in standard C and you requested strict standards compatibility with -std=c99
. That is, a strictly standard C program can do:
JavaScript
#include <signal.h>
int sigset_t;
int main(void) { return 0; }
and expect it to work.