Skip to content
Advertisement

why am i not able to declare sigset_t with std=c99?

If i compile the below program with std=c99, i get an error, but the program compiles fine without the c99 flag. Why?

#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:

#include <signal.h>

int sigset_t;
int main(void) { return 0; }

and expect it to work.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement