GNU C ++如何检查-std = c ++ 0x何时生效? [英] GNU C++ how to check when -std=c++0x is in effect?

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

问题描述

我的系统编译器(gcc42)与我想要的TR1功能正常工作,但试图支持除系统之外的更新的编译器版本,试图访问TR1头一个#error要求-std = c ++ 0x选项,因为

  / usr / local / lib / gcc45 / include / c ++ / bits / c ++ 0x_warning.h:31:2:error:#error此文件需要编译器和库支持即将到来的ISO C ++标准C ++ 0x。此支持目前是实验性的,必须使用-std = c ++ 0x或-std = gnu ++ 0x编译器选项来启用。 

不必提供额外的开关是没有问题的,在这个系统下支持GCC 4.4和4.5 ),但显然它改变了图片!



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

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

使用newer(4.5)版本的编译器与-std = c ++ 0x:

  #include< foo> 
using std :: foo;

有没有使用预处理器,我可以知道g ++是否运行C ++ 0x


$ b p $ p> #ifdef __CXX0X_MODE__
#endif

没有在手册或网络上找到任何东西。



在这个速度,我开始认为生活会更容易,使用Boost作为依赖,并不担心在TR4 ... hehe之前到达的新语言标准。

解决方案

如果使用 -std = c ++ 0x ,则将定义 __ GXX_EXPERIMENTAL_CXX0X __


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.

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!

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

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

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

#include <foo>
using std::foo;

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

Something like this is what I'm looking for:

#ifdef __CXX0X_MODE__
#endif

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

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.

解决方案

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆