用 g++ 编译 c++14 代码

Compile c++14-code with g++(用 g++ 编译 c++14 代码)
本文介绍了用 g++ 编译 c++14 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 14.04 LTS 上使用 g++ 4.8.4.尝试使用 '-std=c++14' 进行编译时,出现此错误:

I'm using g++ 4.8.4 on Ubuntu 14.04 LTS. When trying to compile with '-std=c++14', I get this error:

g++: error unrecognized command line option '-std=c++14'

使用 '-std=c++11' 编译可以正常工作,所以我不确定发生了什么.g++ 真的不支持 c++14 吗?我是否使用了错误的命令行选项?

Compiling with '-std=c++11' works fine, so I'm not sure what's going on. Does g++ really have no support for c++14 yet? Am I using a wrong command line option?

我使用了sudo apt-get install g++",它应该会自动检索最新版本,对吗?

I used "sudo apt-get install g++" which should automatically retrieve the latest version, is that correct?

推荐答案

gcc 4.8.4需要在以后的版本中使用-std=c++1y,看起来从 5.2 开始你可以使用 -std=c++14.

For gcc 4.8.4 you need to use -std=c++1y in later versions, looks like starting with 5.2 you can use -std=c++14.

如果我们查看 gcc 在线文档,我们可以找到每个 gcc 版本的手册,我们可以通过查看4.9.3的方言选项 在 GCC 4.9.3 手册 下它说:

If we look at the gcc online documents we can find the manuals for each version of gcc and we can see by going to Dialect options for 4.9.3 under the GCC 4.9.3 manual it says:

‘c++1y’

ISO C++ 标准的下一个修订版,暂定于 2014 年发布.支持是高度实验性的,并且几乎肯定会在未来的版本中以不兼容的方式发生变化.

The next revision of the ISO C++ standard, tentatively planned for 2014. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.

所以直到 4.9.3 你必须使用 -std=c++1y 而 gcc 5.2 选项 说:

So up till 4.9.3 you had to use -std=c++1y while the gcc 5.2 options say:

‘c++14’‘c++1y’

‘c++14’ ‘c++1y’

2014 ISO C++ 标准加上修订.不推荐使用名称c++1y".

The 2014 ISO C++ standard plus amendments. The name ‘c++1y’ is deprecated.

我不清楚为什么它会列在 Options Controlling C Dialect 下,但这就是当前文档的组织方式.

It is not clear to me why this is listed under Options Controlling C Dialect but that is how the documents are currently organized.

这篇关于用 g++ 编译 c++14 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)