c++ - 打印 gcc 支持的最新 C++ 标准
问题描述
GCC 系列编译器接受一个参数来指定编译器可以使用的语言标准。
例如,gcc
有--std=gnu++20
(或--std=gnu++2a
)和gcc
有--std=gnu18
。
我期望的是一种bash
打印本地支持的最新标准的方法(首选脚本)gcc
。到目前为止,我什至找不到打印本地支持的所有标准的方法gcc
。
注意:不要与以下内容混淆,因为我要求的是最新标准而不是默认标准: 如何找出我的 gcc 默认使用的 ANSI C 标准?
解决方案
非常感谢@ssbssa。这是按预期工作的 bash 脚本的草稿版本
(gcc 10
适用于 C++ 标准):
$ gcc -v --help 2>/dev/null | egrep "gnu\+\+[^I]+ISO [^1]"
-std=gnu++11 Conform to the ISO 2011 C++ standard with GNU extensions.
-std=gnu++14 Conform to the ISO 2014 C++ standard with GNU extensions.
-std=gnu++17 Conform to the ISO 2017 C++ standard with GNU extensions.
-std=gnu++20 Conform to the ISO 2020 C++ draft standard with GNU extensions (experimental and incomplete support). Same as -std=gnu++2a.
-std=gnu++2a Conform to the ISO 2020 C++ draft standard with GNU extensions (experimental and incomplete support).
编辑:脚本的最终版本是:
$ gcc -v --help 2>/dev/null | egrep "gnu\+\+[^I]+ISO [^1]" | egrep -o "\-[^ ]+" | tail -n 1
-std=gnu++2a
推荐阅读
- python - 从 numpy ndarray 中删除零行
- swift - 如何在 Xcode Playground 中使用 SwiftUI?
- python - Flask 开发服务器 WSGI 配置
- angular - 如何在没有控制迭代的情况下使用 Angular 中的 Reactive Form 发送对象数组?
- asp.net - 如何将复选框的值分配给剃刀变量?
- javascript - 如何在 ES6 import 语句中使用全局依赖?
- python - 包含相似功能的类之间的动态切换
- python - 将基于时间的字符串转换为数字
- ace-editor - 为什么 chrome 的灯塔审核不适用于 ace Texteditor
- javascript - 用函数合并两个选项对象