c++ - NS3 - G++ 6.x 关于 c++14 的警告

标签 c++ compiler-errors g++ ns-3

我正在为 Network Simulator 3 编写 C++ 程序,我想使用 C++14 实验性 std::optional。我用 gcc5 编译我的代码,直到我看到像

这样的警告
/usr/include/c++/6/bits/c++14_warning.h:32:2: error: #error This file requires compiler and library support for the forthcoming ISO C++ 2014 standard. This support is currently experimental, and must be enabled with the -std=c++1y or -std=gnu++1y compiler options.

然后我搜索了以 C++14 作为默认标准的 gcc 版本,即 gcc6 ( https://gcc.gnu.org/gcc-6/porting_to.html ) 并安装了它。输入 gcc -v 输出版本 6.3。

但问题是错误依旧存在,不知道下一步该怎么做。任何人都可以给我提示如何解决问题或我应该尝试什么吗?

我的操作系统是 Ubuntu 桌面 16.04。

编辑:

我认为这是一个 ns3 问题,我创建了一个最小的工作示例:

#include <iostream>
#include <experimental/optional>

using namespace std;

// main() is where program execution begins.
int main() {

   cout << "Hello World"; // prints Hello World
   return 0;
}

它按“预期”编译,只是需要注意这个功能是实验性的。我已尝试将每种类型的标志添加到 ns3,但仍然无法编译并输出相同的消息。

g++ -v 输出:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 6.3.0-18ubuntu2~16.04' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170519 (Ubuntu/Linaro 6.3.0-18ubuntu2~16.04)

最佳答案

ns-3 有一个未决的补丁来解决这个问题;它应该出现在未来的 ns-3 版本(ns-3.28)中,或者补丁可以应用于当前和更早的版本: https://www.nsnam.org/bugzilla/show_bug.cgi?id=2800

关于c++ - NS3 - G++ 6.x 关于 c++14 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47179764/

相关文章:

c++ - 无法将字符串与 "y"进行比较

c++ - 排序函数中 'operator=' 不匹配

c++ - 干净地销毁动态分配对象的 vector

excel - ActiveX组件无法创建对象-429

我们可以声明数组的大小为零吗?

inheritance - 为什么在 systemverilog 中继承常量变量不起作用

c++ - 为什么一个简单的C++程序会产生这么多分支命令?在 Linux 上使用性能

c++ - TCP 连接无效连接 block 端口

c++ - 读取到 VC++ 中的 boost 内存映射文件的末尾

c++ - 如何使用 OCCI 中的 setDataBuffer 进行数组提取