gpt4 book ai didi

c - 我们有 c99 子标志吗

转载 作者:行者123 更新时间:2023-12-04 04:54:51 25 4
gpt4 key购买 nike

是否为 -std=c99 提供了子选项,以便我可以通过这些子选项并避免通过 -std=c99?

例如:

int main()
{
for(int i=0;i<10;i++)
{
i++;
}
return 0;
}

我会通过传递任何子选项来用 gcc 编译这段代码。

$ gcc -sub-option-for-c99 a.c

谢谢

编辑:我只想从 C99 中选择一个特性,同时将编译器的其余部分保持在 C89(或其他)模式。

最佳答案

C99 没有太多的子设置功能(基本上没有子设置)。 C11 确实对此有一些规定。但是,实现的细节往往由实现来控制,而不是程序员可以通过诸如 -std=c11 之类的整体开关来更改的东西。或 -std=gnu11 .这是一种冗长的说法“”。

C11 中的子设置示例:附件 K(以前的 TR 24731-1)边界检查接口(interface)。

程序可以通过定义__STDC_WANT_LIB_EXT1__ 来表明它想要使用这些设施。 ,但如果实现本身没有定义 __STDC_LIB_EXT1__,那将无济于事.

来自 ISO/IEC 9899:2011 的更完整的子设置列表(Corr.1 应用于 __STDC_LIB_EXT1__ 的值):

6.10.8.3 Conditional feature macros

¶1 The following macro names are conditionally defined by the implementation:

  • __STDC_ANALYZABLE__ The integer constant 1, intended to indicate conformance to the specifications in annex L (Analyzability).
  • __STDC_IEC_559__ The integer constant 1, intended to indicate conformance to the specifications in annex F (IEC 60559 floating-point arithmetic).
  • __STDC_IEC_559_COMPLEX__ The integer constant 1, intended to indicate adherence to the specifications in annex G (IEC 60559 compatible complex arithmetic).
  • __STDC_LIB_EXT1__ The integer constant 201112L, intended to indicate support for the extensions defined in annex K (Bounds-checking interfaces).179)
  • __STDC_NO_ATOMICS__ The integer constant 1, intended to indicate that the implementation does not support atomic types (including the _Atomic type qualifier) and the <stdatomic.h> header.
  • __STDC_NO_COMPLEX__ The integer constant 1, intended to indicate that the implementation does not support complex types or the header.
  • __STDC_NO_THREADS__ The integer constant 1, intended to indicate that the implementation does not support the <threads.h> header.
  • __STDC_NO_VLA__ The integer constant 1, intended to indicate that the implementation does not support variable length arrays or variably modified types.

¶2 An implementation that defines __STDC_NO_COMPLEX__ shall not define __STDC_IEC_559_COMPLEX__.

179) The intention is that this will remain an integer constant of type long int that is increased with each revision of this International Standard.



另见部分 6.10.8 预定义的宏名称一般用于相关信息。

请注意,这些宏是由实现定义或不定义的,具体取决于它支持或不支持的内容。如果您尝试自己设置它们,那将没有任何区别;它们旨在用于与您进行通信的实现,反之亦然。

ISO/IEC 9899:1999 §6.10.8 预定义的宏名称

¶2 The following macro names are conditionally defined by the implementation:

  • __STDC_IEC_559__ The integer constant 1, intended to indicate conformance to the specifications in annex F (IEC 60559 floating-point arithmetic).
  • __STDC_IEC_559_COMPLEX__ The integer constant 1, intended to indicate adherence to the specifications in informative annex G (IEC 60559 compatible complex arithmetic).
  • __STDC_ISO_10646__ An integer constant of the form yyyymmL (for example, 199712L), intended to indicate that values of type wchar_t are the coded representations of the characters defined by ISO/IEC 10646, along with all amendments and technical corrigenda as of the specified year and month.

¶3 The values of the predefined macros (except for __FILE__ and __LINE__) remain constant throughout the translation unit.

¶4 None of these macro names, nor the identifier defined, shall be the subject of a #define or a #undef preprocessing directive. Any other predefined macro names shall begin with a leading underscore followed by an uppercase letter or a second underscore.

¶5 The implementation shall not predefine the macro __cplusplus, nor shall it define it in any standard header.



6.10.8 节及其子节在 ISO/IEC 9899:2011 中类似,但所讨论的宏集更为广泛。

关于c - 我们有 c99 子标志吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16890917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com