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)?
发布评论
评论(1)
定义它符合实施自身的最大利益。 C17 6.10.8.3:
从技术上讲,编译器可以不定义它,但没有任何意义,如果它确实符合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:
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.