storage size of ‘oldact’ isn’t known

来源:互联网 发布:男生护肤品 知乎 编辑:程序博客网 时间:2024/06/01 13:04
#include <signal.h>

int main()
{
struct sigaction act, oldact;
return 0;
}


dies with the message


testgcc4.c: In function ‘main’:
testgcc4.c:6: error: storage size of ‘act’ isn’t known
testgcc4.c:6: error: storage size of ‘oldact’ isn’t known


if I use -std=c99 or --ansi?
gcc testgcc4.c compiles without problem but adding -std=c99 or --ansi produces
the error message above (for any of gcc-3.4, gcc-4.0, gcc-4.1) but neither

icc nor gcc on FreeBSD has a problem with -std=c99 or --ansi


Sumarry:

use -std=gnu99 on linux if you need some C99 functions (e.g. strtof) but also want to use functions like sigaction and strtok_r

gcc on linux is stricter than gcc on FreeBSD (or icc on either FreeBSD or linux) concerning standards.
gcc -std=c99 on linux means: *only* recognize functions specified in the standard (no sigaction, no strtok_r etc)
gcc -std=c99 on FreeBSD or icc -std=c99 on either FreeBSD or linux means recognize functions specified in the standard. This corresponds more or less to -std=gnu99 on linux

PS. This trap seems to be quite common (e.g. discussions on debian-glibc about the "fact" that strtof is completely broken on linux). I would be grateful if somebody could point me to a good overview describing what standards compliance means for various OS/compiler+options/standards combinations.