加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

对于C 17,__cplusplus的值是多少?

发布时间:2020-12-16 03:42:35 所属栏目:百科 来源:网络整理
导读:我们试图在C 17和它的 change to std::uncaught_exception 下测试一些代码.我似乎无法让GCC提供__cplusplus的值: $/opt/local/bin/g++ -std=c++17 -dM -E - /dev/null | grep __cpluspluscc1: warning: command line option '-std=c++1z' is valid for C++/
我们试图在C 17和它的 change to std::uncaught_exception下测试一些代码.我似乎无法让GCC提供__cplusplus的值:
$/opt/local/bin/g++ -std=c++17 -dM -E - </dev/null | grep __cplusplus
cc1: warning: command line option '-std=c++1z' is valid for C++/ObjC++ but not for C
$

和:

$/opt/local/bin/g++ --version
g++-mp-6 (MacPorts gcc6 6.1.0_0) 6.1.0
Copyright (C) 2016 Free Software Foundation,Inc.

使用C 17时__cplusplus的值是多少?

解决方法

What is the value of __cplusplus when using C++17?

根据标准草案N4594§16.8/ p1预定义的宏名称[cpp.predefined](Emphasis Mine):

The following macro names shall be defined by the implementation:
__cplusplus The name __cplusplus is defined to the value
201402L when compiling a C++ translation unit.156

156) It is intended that future versions of this standard will
replace the value of this macro with a greater value. Non-conforming
compilers should use a value with at most five decimal digits.

然而,对于C14标准指定的价值相同.显然,似乎这样,没有为C 17标准设定的官方/标准__cplusplus值.

在GCC 6.1和7.0版中,值更改为201500

Live Demo

在Clang版本3.8和3.9中,值不变201406.

因此,您必须稍等一点才能出现标准值.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读