我的系统编译器(gcc42)可以正常使用我想要的TR1功能,但是试图支持除系统之外的新编译器版本,尝试访问TR1标头和#error要求-std = c ++ 0x选项因为它如何与库或某些集线器接口.
/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.
Run Code Online (Sandbox Code Playgroud)
必须提供额外的开关是没有问题的,在这个系统(FreeBSD)下支持GCC 4.4和4.5,但显然它改变了画面!
使用我的系统编译器(g ++ 4.2默认方言):
#include <tr1/foo>
using std::tr1::foo;
Run Code Online (Sandbox Code Playgroud)
使用带有-std = c ++ 0x的较新(4.5)版本的编译器:
#include <foo>
using std::foo;
Run Code Online (Sandbox Code Playgroud)
无论如何使用预处理器,我可以判断g ++是否在启用C++ 0x功能的情况下运行?
我正在寻找的东西是这样的:
#ifdef __CXX0X_MODE__
#endif
Run Code Online (Sandbox Code Playgroud)
但是我没有在手册中或网上找到任何内容.
按照这个速度,我开始认为生活会更容易,使用Boost作为依赖,而不用担心在TR4之前到达的新语言标准......呵呵.