Linux 下centos 查看 -std这个编译时命令 是否支持 C17

简介: Linux 下centos 查看 -std这个编译时命令 是否支持 C17

实际工作中,可能会遇到c++的一些高级特性,例如std::invoke,此函数是c++17才引入的,如何判断当前的gcc是否支持c++17呢,这里提供两种办法。

根据gcc的版本号来推断

gcc --version,可以查看版本号,笔者的电脑,gcc的版本号是8.3.0,然后查看8.3.0是什么时候发布的,查出是2019年发布的,从而推断出是支持,但是不是十分肯定,所以接着看第二种方法

  1. 根据gcc的版本号来推断

gcc --version,可以查看版本号,笔者的电脑,gcc的版本号是8.3.0,然后查看8.3.0是什么时候发布的,查出是2019年发布的,从而推断出是支持,但是不是十分肯定,所以接着看第二种方法

  1. 直接man gcc

上图中,红色方框-std=表示支持的标准项,可以看到c11,c17之类的


centos 本身自带的版本是不支持到C17的。截取 man gcc如下

 -std=
           Determine the language standard.   This option is currently only supported when compiling C or
           C++.

           The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those
           standards, such as gnu90 or gnu++98.  When a base standard is specified, the compiler accepts all
           programs following that standard plus those using GNU extensions that do not contradict it.  For
           example, -std=c90 turns off certain features of GCC that are incompatible with ISO C90, such as
           the "asm" and "typeof" keywords, but not other GNU extensions that do not have a meaning in ISO
           C90, such as omitting the middle term of a "?:" expression. On the other hand, when a GNU dialect
           of a standard is specified, all features supported by the compiler are enabled, even when those
           features change the meaning of the base standard.  As a result, some strict-conforming programs
           may be rejected.  The particular standard is used by -Wpedantic to identify which features are
           GNU extensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about
           C++ style // comments, while -std=gnu99 -Wpedantic does not.


            A value for this option must be provided; possible values are

           c90
           c89
           iso9899:1990
               Support all ISO C90 programs (certain GNU extensions that conflict with ISO C90 are
               disabled). Same as -ansi for C code.

           iso9899:199409
               ISO C90 as modified in amendment 1.

           c99
           c9x
           iso9899:1999
           iso9899:199x
               ISO C99.  Note that this standard is not yet fully supported; see
               <http://gcc.gnu.org/c99status.html> for more information.  The names c9x and iso9899:199x are
               deprecated.

           c11
           c1x
           iso9899:2011
               ISO C11, the 2011 revision of the ISO C standard.  Support is incomplete and experimental.
               The name c1x is deprecated.

           gnu90
           gnu89
               GNU dialect of ISO C90 (including some C99 features). This is the default for C code.

           gnu99
           gnu9x
               GNU dialect of ISO C99.  When ISO C99 is fully implemented in GCC, this will become the
               default.  The name gnu9x is deprecated.

           gnu11
           gnu1x
               GNU dialect of ISO C11.  Support is incomplete and experimental.  The name gnu1x is
               deprecated.

           c++98
           c++03
               The 1998 ISO C++ standard plus the 2003 technical corrigendum and some additional defect
               reports. Same as -ansi for C++ code.

           gnu++98
           gnu++03
               GNU dialect of -std=c++98.  This is the default for C++ code.

           c++11
           c++0x
               The 2011 ISO C++ standard plus amendments.  Support for C++11 is still experimental, and may
               change in incompatible ways in future releases.  The name c++0x is deprecated.
 gnu++11
           gnu++0x
               GNU dialect of -std=c++11. Support for C++11 is still experimental, and may change in
               incompatible ways in future releases.  The name gnu++0x is deprecated.

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

           gnu++1y
               GNU dialect of -std=c++1y.  Support is highly experimental, and will almost certainly change
               in incompatible ways in future releases.

分享一个有趣的 学习链接:https://xxetb.xet.tech/s/HY8za


目录
相关文章
|
19小时前
|
安全 Linux Shell
Linux中SSH命令介绍
Linux中SSH命令介绍
9 2
|
20小时前
|
NoSQL 关系型数据库 MySQL
linux服务器重启php,nginx,redis,mysql命令
linux服务器重启php,nginx,redis,mysql命令
6 1
|
1天前
|
Linux 应用服务中间件 nginx
linux下的查找命令
linux下的查找命令
9 0
|
1天前
|
存储 Linux 程序员
tar命令详解:linux文件打包神器
tar命令详解:linux文件打包神器
|
1天前
|
监控 Unix Linux
Linux中grep命令详解
Linux中grep命令详解
|
1天前
|
Linux 数据处理
Linux中sort命令详解
Linux中sort命令详解
|
1天前
|
弹性计算 安全 Cloud Native
Alibaba Cloud Linux镜像系统超好用!兼容CentOS生态,性能稳定性绝对可以!
Alibaba Cloud Linux是阿里云的自研Linux发行版,兼容CentOS/RHEL,提供长期免费支持。它针对云服务器ECS优化,适用于多种场景,如Web服务、云原生应用等。Alibaba Cloud Linux 3基于Anolis OS 8,提供安全、高性能、十年维护及丰富的开源生态。用户可在ECS购买时选择镜像安装,支持多架构并提供热补丁、解决方案和快速启动版。更换ECS操作系统是免费的。
30 5
|
10月前
|
存储 Linux Shell
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)(下)
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)
392 0
|
10月前
|
分布式计算 Hadoop Linux
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)(上)
虚拟机安装(安装(克隆)虚拟机 配置网络 安装Centos7 配置(修改)虚拟机的静态IP 修改网卡的配置文件 测试网络是否互通外部工具 连接linux系统 设置服务器时间 修改主机名)
320 0
|
Ubuntu Oracle 安全
CentOS 将于年底终止!Linux服务器该何去何从?
CentOS 将于年底终止!Linux服务器该何去何从?
568 0
CentOS 将于年底终止!Linux服务器该何去何从?