GCC编译 C与C++ C89与C99

Wesley13
• 阅读 1005
  1. 最初的 ANSI C 标准 (X3.159-1989) 在 1989 年被批准,并于 1990 年发布。稍后这个标准被接受为 ISO 标准 (ISO/IEC 9899:1990) 。虽然 ISO 标准将 ANSI 标准的某些章节重新编号并变为条款,但是两者实际上并无区别。不论是 ANSI 标准还是 ISO 标准,通常都称之为 C89 ,偶尔也因为发布日期而被叫做 C90 。 ANSI 标准 ( 非 ISO 标准 ) 同时附带了 rationale 文档。可以使用 -ansi , -std=c89 或 -std=iso9899:1990 选项指定 GCC 使用 C89 标准;可以使用 -pedantic 选项来得到所有的诊断信息( 或者使用 -pedantic-errors 选项以使 wangning 变为 error) 。PS:pedantic adj. 1. 卖弄学问的 2. 学究式的,迂腐的

  2. 新的 ISO C 标准是 1999 年发布的 ISO/IEC 9899:1999 ,通常称之为 C99 。 GCC 目前不完整的支持这个版本。详情请参考 http://gcc.gnu.org/gcc-4.4/c99status.html 。为了指定 GCC 使用这个版本的 C 标准,需要 -std=c99 或 -std=iso9899:1999 选项。

  3. 默认情况下, GCC 提供了一些 C 语言的扩展,极少的几处会与 C 标准冲突。关于这些冲突请参考 “ C 语言家族的扩展 ” 一节。使用上述的 -std 选项将会关闭这些有冲突的扩展。你也可以显式的使用选项 -std=gnu89 ( 对应 C89 的 GNU 扩展 ) 或 -std=gnu99 ( 对应 C99 的 GNU 扩展 ) 来选择对应版本的扩展功能。如果没有给出 C 语言 “ 方言 ” 选项,将默认的使用 -std=gnu89 ;若要使用C99的特性要设置-std=gnu9x。

gcc下的语言规范设置:
-std=iso9899:1990,-ansi或-std=c89 (三者完全等同)来指定完全按照c89规范,而禁止gcc对c语言的扩展。
-std=iso9899:199409 使用C95规范
-std=c99 或者 -std=iso9899:1999 使用C99规范。
-std=gnu89 使用c89规范加上gcc自己的扩展(目前默认)
-std=gnu99 使用c99规范加上gcc自己的扩展

4)-std= 选择C语言编译标准

-std=

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. 

`c1x'

ISO C1X, the draft of the next revision of the ISO C standard. Support is limited and experimental and features enabled by this option may be changed or removed if changed in or removed from the standard draft. 

`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. 

`gnu1x'

GNU dialect of ISO C1X. Support is limited and experimental and features enabled by this option may be changed or removed if changed in or removed from the standard draft. 

`c++98'

The 1998 ISO C++ standard plus amendments. Same as -ansi for C++ code. 

`gnu++98'

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

`c++0x'

The working draft of the upcoming ISO C++0x standard. This option enables experimental features that are likely to be included in C++0x. The working draft is constantly changing, and any feature that is enabled by this flag may be removed from future versions of GCC if it is not part of the C++0x standard. 

`gnu++0x'

GNU dialect of -std=c++0x. This option enables experimental features that may be removed in future versions of GCC.

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Karen110 Karen110
2年前
一篇文章带你了解JavaScript日期
日期对象允许您使用日期(年、月、日、小时、分钟、秒和毫秒)。一、JavaScript的日期格式一个JavaScript日期可以写为一个字符串:ThuFeb02201909:59:51GMT0800(中国标准时间)或者是一个数字:1486000791164写数字的日期,指定的毫秒数自1970年1月1日00:00:00到现在。1\.显示日期使用
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Wesley13 Wesley13
2年前
C 如何判断编译器是否支持C90 C99?
参考:《CPrimerPlus》,StephenPrata著,姜佑译。ANSI/ISOC标准美国ANSI成立委员会X3J11,于89/90年,99年,11年,发布C标准:C89/C90,C99,C11。ANSI/ISO各版本C标准C标准描述经典C也称K&RC,87年K&R著作《C语言程序设计》,
Stella981 Stella981
2年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Stella981 Stella981
2年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Stella981 Stella981
2年前
Impala常用函数索引
增加X自然天selectdays_add(now(),2)字符串转Timestampselectto\_timestamp('2019101420:00:01','yyyyMMddHH:mm:ss');注意,Impala的timestamp的标准是ISO8601 参考:https://en.wiki
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
3个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这