c++ - 如何判断您的编译器支持哪个版本的 ISO C++ 标准?

标签 c++ c++11 standards

<分区>

Possible Duplicate:
How to determine the version of the C++ standard used by the compiler?

您的程序有没有办法在编译时确定这一点?是否有可以使用的预处理器宏?

我知道 g++ 有这个 nice matrix of c++0x/c++11 feature support .这是否适用于其他流行的编译器?是否有任何标准(事实上或其他方式)使用预处理器来测试给定功能是否存在?

有一个关于这个的问题,但答案似乎不是很完整:How to determine the version of the C++ standard used by the compiler?

我知道 Boost.Config 会这样做,但它是如何做到的呢?很高兴知道我是否出于某种原因不想使用 Boost。

我将其作为拷贝关闭,因为有人编辑了其中一个 answers in the original question更加完整。

最佳答案

查看__cplusplus的值

In C++0x the macro __cplusplus will be set to a value that differs from (is greater than) the current 199711L.

http://predef.sf.net对检测特定标准具有一定的值(value)。

Boost.Config recommendation关于您链接到的问题也是很好的建议,并提供了更细粒度的答案。我认为它基本上编纂了 feature matrix并定期更新。

关于c++ - 如何判断您的编译器支持哪个版本的 ISO C++ 标准?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7132540/

相关文章:

c++ - 将 ruby​​ 库静态链接到 C++ 应用程序

c++ - 如何将变体参数传递给 C++ 中的 DBUS 方法调用?

c++ - 原始数组是否比 std::array 有任何优势?

c++ - thread_guard 与 scoped_thread

c - 为什么 <sys/types.h> 中的 uint 使用 -std=c99 消失了?

c++ - 关于对象初始化语义的问题

c++ - gluTessCallback 错误 C2440

c++ - 为什么需要使用 unordered_map 和元组的默认构造函数?

c++ - STL 有序容器如何知道它们的结束?

php - 定义目录时末尾有/没有 '/' 有什么区别?