GNU C++ 如何检查 -std=c++0x 何时生效?

GNU C++ how to check when -std=c++0x is in effect?(GNU C++ 如何检查 -std=c++0x 何时生效?)
本文介绍了GNU C++ 如何检查 -std=c++0x 何时生效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我的系统编译器 (gcc42) 与我想要的 TR1 功能配合得很好,但尝试支持系统以外的较新编译器版本,尝试访问 TR1 标头时出现 #error 要求 -std=c++0x 选项,因为了解它如何与图书馆或类似的一些集线器连接.

My system compiler (gcc42) works fine with the TR1 features that I want, but trying to support newer compiler versions other than the systems, trying to accessing TR1 headers an #error demanding the -std=c++0x option because of how it interfaces with library or some hub bub like that.

/usr/local/lib/gcc45/include/c++/bits/c++0x_warning.h:31:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.

必须提供一个额外的开关是没有问题的,在这个系统(FreeBSD)下支持GCC 4.4和4.5,但显然它改变了画面!

Having to supply an extra switch is no problem, to support GCC 4.4 and 4.5 under this system (FreeBSD), but obviously it changes the picture!

使用我的系统编译器(g++ 4.2 默认方言):

Using my system compiler (g++ 4.2 default dialect):

#include <tr1/foo>
using std::tr1::foo;

通过 -std=c++0x 使用更新 (4.5) 版本的编译器:

Using newer (4.5) versions of the compiler with -std=c++0x:

#include <foo>
using std::foo;

无论如何使用预处理器,我可以判断 g++ 是否在启用 C++0x 功能的情况下运行?

Is there anyway using the pre processor, that I can tell if g++ is running with C++0x features enabled?

我正在寻找这样的东西:

#ifdef __CXX0X_MODE__
#endif

但我没有在手册或网上找到任何内容.

but I have not found anything in the manual or off the web.

以这种速度,我开始认为生活会更轻松,使用 Boost 作为依赖项,而不用担心在 TR4 之前出现新的语言标准......呵呵.

At this rate, I'm starting to think that life would just be easier, to use Boost as a dependency, and not worry about a new language standard arriving before TR4... hehe.

推荐答案

如果你用 -std=c++0x 编译,那么 __GXX_EXPERIMENTAL_CXX0X__ 将被定义.

If you compile with -std=c++0x, then __GXX_EXPERIMENTAL_CXX0X__ will be defined.

这篇关于GNU C++ 如何检查 -std=c++0x 何时生效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
STL BigInt class implementation(STL BigInt 类实现)
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)