如何在Mac上启用C ++ 17?

编程入门 行业动态 更新时间:2024-10-20 03:31:22
本文介绍了如何在Mac上启用C ++ 17?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我能够在Linux上更新gcc以获得-std = c ++ 17,但在Mac上却无法做到这一点.是否有我可以更新到的Clang版本或在Mac上获得C ++ 17的其他替代版本?请帮忙.谢谢.

I am able to update gcc on Linux to get -std=c++17 but cannot do the same on Mac. Is there a version of Clang I can update to or some other alternative to get C++17 on my Mac? Please help. Thanks.

推荐答案

在我的10.11 El Capitan Xcode 7.3.1上,c已更新为:

On my 10.11 El Capitan, Xcode 7.3.1, clang has been updated to:

Apple LLVM version 7.3.0 (clang-703.0.31)

几乎等同于llvm 3.8版. clang++没有-std=c++17选项,但是-std=c++1z目前运行良好,尽管它仅支持C ++ 1z的某些功能.

which is almost equivalent to llvm version 3.8. clang++ hasn't -std=c++17 option, but -std=c++1z, working well at present, though only supporting some features of C++1z.

对于gcc,您可以通过以下方式安装一个非常新的版本:

For gcc, you can install a very new one by:

brew install gcc --HEAD

它将立即安装gcc-6.1(2016.8).此gcc对C ++ 17的支持有限,可以通过-std=c++17启用.

which will install gcc-6.1 now, (2016.8). This gcc has limited support for C++17 and can be enabled by -std=c++17.

一些更新:

Apple clang的对应llvm版本最近不清楚,应为3.9+或4+.查看此Wiki页面以获取更多信息.

The corresponding llvm version of Apple's clang is not clear recently, should be 3.9+ or 4+. Check this wiki page for more information.

brew install gcc --HEAD应该始终适用于mac/homebrew,并为您提供具有许多实验功能的尖端gnu gcc.另一方面,普通brew install gcc现在应该安装支持大多数c ++ 17功能的gcc.

brew install gcc --HEAD should always work for mac/homebrew, and give you the cutting edge gnu gcc with many experimental features. On the other hand, normal brew install gcc should install a gcc supporting most c++17 features now.

对于语言标准参数,对于不同的编译器请尝试-std=c++17和-std=c++1z,其中之一应该可以工作.

For the language standard argument, try -std=c++17 and -std=c++1z for different compilers, one of them should work.

更多推荐

如何在Mac上启用C ++ 17?

本文发布于:2023-11-29 20:29:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647544.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Mac

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!