![](/img/trans.png)
[英]Why don't non-strict floating-point models change the value 1 of __STDC_IEC_559__?
[英]Why isn't an IEC 60559 conformant implementation required to define __STDC_IEC_559__ (to 1)?
C (C99+) 標准要求(雖然隱含地)一個符合要求的實現來將__STDC__
定義為 1。
但是,C 標准不需要符合 IEC 60559 的實現來定義__STDC_IEC_559__
(為 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)?
定義它符合實現自身的最大利益。 C17 6.10.8.3:
__STDC_IEC_559__
integer 常量1
,旨在表明符合附件 F(IEC 60559 浮點運算)中的規范。
雖然從技術上講編譯器可以不定義它,但如果它確實符合 IEC 60559,那么不定義它是沒有任何意義的。它是實現質量的標記,就像__STDC__
或__STDC_VERSION__
。
值得注意的是,此常量自 C99 以來一直存在,因此 C90 實現可能會在不定義宏常量的情況下使用 IEC 60559。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.