我知道编译器使用 __STDC__
来指示编译器是标准 C,从那里,您可以使用 __STDC_VERSION__
来确定哪个级别 您正在使用的标准。
我也知道 C90 没有值,C90 修正案 1 有 199401L
,C99 有 199901L
。
我将最新的 C1x 草案简单地表述为 201ymmL
,并且我假设它在最终标准中的值变得不那么“模糊”。
我的猜测是 201112L
因为那是 C11 获得批准的时间,但我想确定一下。
我想我可以尝试使用 gcc -std=c1x
但我正在运行的 gcc
版本还不支持它。
有谁知道实际值是多少?
最佳答案
在 gcc
中使用 -std=c11
,201112L
用于 __STDC_VERSION__
请参阅 2011 年 12 月 20 日在 gcc
ml 上的此 gcc
补丁:
https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg23572.html
请注意,C11 的 ISO 版本显然忘记更新草案中的 201ymmL
。
The intended final
__STDC_VERSION__
value,201112L
, is also implemented (the editor forgot to update the201ymmL
placeholders before sending the document for publication by ISO).
另见 DR #411 ,这正式表明预期值为 201112l
。小编说过"The committee is trying to get it approved as a TC as soon as possible." . (TC = "技术勘误表")
编辑(2012 年 7 月 16 日): 2012 年 7 月 15 日发布的技术勘误 1 ( ISO/IEC 9899:2011/Cor 1:2012 ) 将 __STDC_VERSION__
修复为 201112L
.
关于c - C11 的 __STDC_VERSION__ 值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9294207/