- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我们正在尝试在 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
的值是多少?
最佳答案
__cplusplus
是 201703L
。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 value201402L when compiling a C++ translation unit.156156) It is intended that future versions of this standard willreplace the value of this macro with a greater value. Non-conformingcompilers should use a value with at most five decimal digits.
但是,为 C++14 标准指定了相同的值。显然,目前还没有为 C++17 标准设置官方/标准 __cplusplus
值。
在 GCC 版本 6.1 和 7.0 中,该值更改为 201500
在 Clang 版本 3.8 和 3.9 中,该值保持不变201406。
因此,您必须稍等片刻才能得出标准值。
根据 C++ 标准§19.8/p1 预定义的宏名称 [cpp.predefined](Emphasis Mine):
1 The following macro names shall be defined by theimplementation:
__cplusplus
The integer literal 201703L.
因此,使用C++17时__cplusplus
的值为201703L。
关于c++ - __cplusplus 对于 C++17 的值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38456127/
我是否正确理解这些是 __cplusplus 的最小值并且 C++98 具有与 C++03 相同的值? // C++ 98 #define __cplusplus 199711L // C++ 03
这个问题在这里已经有了答案: Combining C++ and C - how does #ifdef __cplusplus work? (4 个答案) 关闭 8 年前。 我在使用 eclips
C++ 宏 __cplusplus 包含和扩展到什么? 即使在最古老的 C++ 实现中,宏 __cplusplus 是否始终包含并扩展为一个数字值? 使用#if __cplusplus是否安全还是我们
这个问题在这里已经有了答案: How are the __cplusplus directive defined in various compilers? (4 个答案) 关闭 5 年前。 问题是
我的编译器将其扩展为 199711L。这意味着什么?我读到 __cplusplus > 199711L 表示 C++11。这个宏有哪些可能的扩展,它意味着什么? 最佳答案 199711L 代表 Yea
我想取消定义并重新定义 __cplusplus 宏,但出现编译错误:__cplusplus 未在此范围内声明 #define TEMP_VERSION __cplusplus // temporary
在我的 Ubuntu Netbeans 7.3 安装中,我有一个 C++ 项目,在 C++ 编译器选项中将 C++11 标记为标准。当我尝试包含 时它似乎没有使 std::chrono命名空间可用。
python源码中头文件中的follow有什么用 #ifdef __cplusplus extern "C" { #endif 这是否意味着 Python 为我们提供了使用 C++ 编译器构建代码的能
#ifdef __cplusplus // C++ code #else // C code #endif 结构是这样的。我的问题是,如何真正触发 #ifdef on? 我的意思是,在程序中?我写什么
标准要求现代 C++ 编译器 #define 宏 __cplusplus。 这通常用于 C 和 C++ 都可以使用的文件中,但实现方式略有不同。 但在 C(和 C++)中,在标识符中使用任何双下划线的
我混合了 C C++ 代码。全部用g++编译。只要有 C 头文件,我就会在其中包含头文件的内容 #if defined(__cplusplus) extern "C" { #endif 和 #if d
内部外部 "C" { }宏 __cplusplus仍然被定义。当我想包含 mpi.h 的 C 版本时在动态加载的我的库的标题中,这将不能作为 mpi.h 工作仍然找到 __cplusplus并且仍然会
我们正在尝试在 C++17 及其 change to std::uncaught_exception 下测试一些代码。 .我似乎无法让 GCC 提供 __cplusplus 的值: $ /opt/lo
Gnu C++ 编译器似乎将 __cplusplus 定义为 1 #include int main() { std::cout 201100L # define MYNULL nullpt
我正在寻找设置一些预处理器的东西,我想要一个更准确的数字来说明 C++14 中的 __cplusplus 应该被定义为什么。该标准是否规定了一项? 最佳答案 N3936* §16.8 [cpp.pre
我想知道放在哪里比较好 #ifdef __cplusplus extern "C" { #endif 在 C 头文件中。 在所有其他包含的开头或之后。为什么? 最佳答案 对此没有严格的规定,但要注意以
我正在尝试在我的项目中运行 C++11。我将编译器标志 /std:c++11 添加到编译器,但是当我检查版本并打印出来时,它显示为 C++98。这是在 Visual Studio 2019 中。 这是
有人知道为什么 __cplusplus 在我的 Visual Studio 2012 c++ 项目中被定义为 199711L(这是“旧的”C++)吗?它不应该说 201103L 因为 VS 2012
我在启用了 C++17 的 QtCreator 中使用了一个 CMake 项目。 我可以毫无问题地编译和使用 C++17 功能。打印 __cplusplus 的值时我得到 201703 ,但是当我将鼠
为什么不应该为需要定义为 C 函数的函数指定 extern "C"?将文件编译为 C 源代码时,会对编译器产生什么影响? 如果对 C 编译器没有影响,难道我们不能像下面那样通过删除 #ifdef __
我是一名优秀的程序员,十分优秀!