GNU C++ how to check when -std=c++0x is in effect?(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 何时生效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:GNU C++ 如何检查 -std=c++0x 何时生效?
基础教程推荐
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
