• storage size of ‘oldact’ isn’t known


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

    上面的代码使用-std=gnu99正常通过。

    man gnu:

    c99
    c9x
    iso9899:1999
    iso9899:199x
    ISO C99. Note that this standard is not yet fully supported; see <http://gcc.gnu.org/c99status.html> for
    more information. The names c9x and iso9899:199x are deprecated.

    gnu99
    gnu9x
    GNU dialect of ISO C99. When ISO C99 is fully implemented in GCC, this will become the default. The name
    gnu9x is deprecated.

     参考 :http://blog.csdn.net/cccallen/article/details/8440175

  • 相关阅读:
    561. Array Partition I
    448. Find All Numbers Disappeared in an Array
    136. Single Number
    485. Max Consecutive Ones
    463. Island Perimeter
    496. Next Greater Element I
    344. Reverse String
    【.net项目中。。】.net一般处理程序使用方法
    【ExtAspNet学习笔记】ExtAspNet控件库中常见问题
    用VS2010创建三层架构开发模式及三层架构的研究
  • 原文地址:https://www.cnblogs.com/youxin/p/4042559.html
Copyright © 2020-2023  润新知