NS3-G++;6.x关于c+的警告+;14 我正在编写一个用于网络仿真器3的C++程序,我想用C++ 14的实验STD::可选的。我正在用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.

NS3-G++;6.x关于c+的警告+;14 我正在编写一个用于网络仿真器3的C++程序,我想用C++ 14的实验STD::可选的。我正在用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++,compiler-errors,g++,ns-3,C++,Compiler Errors,G++,Ns 3,然后我搜索了以C++14作为默认标准的gcc版本,即gcc6(),并安装了它。键入gcc-v输出版本6.3 但问题是错误仍然存在,我不知道下一步该怎么做。有没有人能给我一些提示,告诉我如何解决这个问题,或者我应该做些什么 我的操作系统是Ubuntu桌面16.04 编辑: 我认为这是一个ns3问题,我创建了一个最小的工作示例: #include <iostream> #include <experimental/optional> using namespace std;

然后我搜索了以C++14作为默认标准的gcc版本,即gcc6(),并安装了它。键入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;
}

似乎标志-std=c++11是在ns3的根wscript文件中硬编码的。这个答案帮助我改变了它。

ns-3有一个挂起的补丁来修复这个问题;它应该出现在未来的ns-3版本(ns-3.28)中,或者该修补程序可以应用于当前和早期版本:

@IgnacioVazquez Abrams不,我已经阅读了这条消息,问题是如果C++14是标准的,为什么要输出这条消息?@IgnacioVazquez Abrams OP已经阅读了这条消息,并在他们的问题中提供了他们质疑的根源:根据GCC文档,该版本可以处理C++14,但其标准库实现中的一个文件表明并非如此。std::optional没有将其写入C++14,但它正在C++17中进行标准化。您是否尝试使用-std=c++1z进行编译?我们是否可以使用一个:最小包含来获得此错误?在投诉文件中,它有一行:
#if u cplusplus
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)