c/c++语言开发共享C11可选function宏在哪里?

在C11标准中写道,编译器应该提供一些宏来测试可选的function存在。 我在哪个标题中找到它们?

例如, __STDC_NO_VLA__位于__STDC_NO_VLA__

使用GCC,即,如果我尝试在complex.h找到__STDC_NO_COMPLEX__我在那里找不到…

    它们没有在任何头中定义,编译器将自己定义它们。

    您可以转储所有预处理器定义。 例如对于gcc写:

     gcc -dM -E - < /dev/null 

    例如对我来说:

     bob@bob-fedora:~/trunk/software$ gcc --version gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bob@bob-fedora:~/trunk/software$ gcc -std=gnu11 -dM -E - < /dev/null | grep STDC #define __STDC_HOSTED__ 1 #define __STDC_UTF_16__ 1 #define __STDC_VERSION__ 201112L #define __GNUC_STDC_INLINE__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1 

    在您给出的示例中, __STDC_NO_VLA__存在这意味着编译器不支持可变长度数组。 你可以写:

     #ifdef __STDC_NO_VLA__ #error Your compiler does not support VLAs! Please use a supported compiler. #endif 

    要么

     #ifndef __STDC_NO_VLA__ // code using variable length arrays #else // fallback code for when they are not supported #endif 

    如果定义了STDC_NO_COMPLEX ,则表示没有complex.h

    STDC_NO_COMPLEX由编译器定义,而不是由头文件定义

    来源: http : //en.cppreference.com/w/c/numeric/complex

      以上就是c/c++开发分享C11可选function宏在哪里?相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/544644.html

      (0)
      上一篇 2021年1月9日
      下一篇 2021年1月9日

      精彩推荐