为什么定义__STDC_IEC_559__(至1)需要的IEC 60559符合实现?

发布于 2025-01-26 16:45:23 字数 472 浏览 2 评论 0 原文

C(C99+)标准需要(尽管隐式)定义 __ stdc __ 至1至1的符合实现。

但是,C标准不需要IEC 60559以定义 __ stdc_iec_iec_559 __ __ __ __ __ __ __ code> (至1)。

后果:

#if __STDC__ != 1
/* non-conforming implementation */
#endif

#if __STDC_IEC_559__ != 1
/* may be IEC 60559 conformant implementation */
#endif

在这里,我们看到这些宏的语义没有一致性。有什么想法吗?是可能的缺陷吗?

为什么C标准不需要IEC 60559符合实现来定义 __ stdc_iec_559 __ (至1)?

The C (C99+) standard requires (though implicitly) a conforming implementation to define __STDC__ to 1.

However, the C standard does not require an IEC 60559 conformant implementation to define __STDC_IEC_559__ (to 1).

Consequences:

#if __STDC__ != 1
/* non-conforming implementation */
#endif

#if __STDC_IEC_559__ != 1
/* may be IEC 60559 conformant implementation */
#endif

Here we see that there is no consistency in the semantics of these macros. Any ideas why? Is it a possible defect?

Why the C standard does not require an IEC 60559 conformant implementation to define __STDC_IEC_559__ (to 1)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟沫凡尘 2025-02-02 16:45:23

定义它符合实施自身的最大利益。 C17 6.10.8.3:

__ stdc_iec_559 __ 整数常数 1 ,旨在指示符合符合的
附件F中的规格(IEC 60559浮点算术)。

从技术上讲,编译器可以不定义它,但没有任何意义,如果它确实符合IEC 60559。或 __ stdc_version __

值得注意的是,该常数自C99以来才存在,因此C90实现可能在不定义宏常数的情况下使用IEC 60559。

It's in the implementation's own best interest to define it. C17 6.10.8.3:

__STDC_IEC_559__ The integer constant 1, intended to indicate conformance to the
specifications in annex F (IEC 60559 floating-point arithmetic).

While it technically would be possible for the compiler not to define it, it doesn't make any sense not to, in case it does conform to IEC 60559. It's a quality of implementation stamp, just like __STDC__ or __STDC_VERSION__.

Notably, this constant has only been around since C99, so it would be possible that C90 implementations use IEC 60559 without defining the macro constant.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文