has*_*paa 4 c++ gcc waf ns-3 c++11
我需要在网络模拟器NS-3的代码中使用像unordered_map这样的数据结构.它使用waf builder来编译源代码.我很困惑,我应该在哪里添加-std = c ++ 0x添加到编译器标志?我尝试使用以下命令将其附加到主wscript文件中的CXXFlags:
module.env.append_value('CXXFLAGS', '-std=c++0x');
Run Code Online (Sandbox Code Playgroud)
但我仍然收到此错误:
此文件需要编译器和库支持即将推出的ISO C++标准C++ 0x.此支持目前是实验性的,必须使用-std = c ++ 0x或-std = gnu ++ 0x编译器选项启用.C/C++问题
我是否还应该将任何库添加到我的waf模块中?
PS:我的GCC版本是4.4
更新:更新到4.7后,我收到此错误:
error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
Run Code Online (Sandbox Code Playgroud)
有没有办法告诉编译器使用0x而不是11?
这是解决方案:
首先,将GCC升级到4.7以换取Ns-3会因标准的变化而导致更多错误,并且无法解决问题.所以我把gcc和g ++改回4.4.3.
但是为了摆脱这个错误(正如它所说),这个选项应该添加到CXXFLAGS:
-std=c++0x
Run Code Online (Sandbox Code Playgroud)
要向CXXFLAG添加选项,您可以使用:
CXXFLAGS="-std=c++0x" ./waf configure
Run Code Online (Sandbox Code Playgroud)
或者如果你想为waf configure添加选项:
CXXFLAGS="-std=c++0x" ./waf -d debug --enable-examples --enable-tests configure
Run Code Online (Sandbox Code Playgroud)