当前GCC的默认C -std标准版本是什么(尤其是在Ubuntu上)? [英] What is the default C -std standard version for the current GCC (especially on Ubuntu)?

查看:375
本文介绍了当前GCC的默认C -std标准版本是什么(尤其是在Ubuntu上)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我要求查看cc的当前版本时,我得到了这个.

When I ask to see the current version of cc I get this.

$ cc --version
cc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ 

我想知道的是正在使用c89,c90,c99或c11中的哪个.

What I would like to know is which of c89, c90, c99 or c11 is being used.

推荐答案

这在gcc手册中有详细解释,可通过键入info gcc或在线此处

This is explained in depth in the gcc manual, available (if it's installed) by typing info gcc or online here. The relevant section of the 4.7.2 manual is here.

默认情况下,gcc不符合任何ANSI/ISO C标准.当前默认值等效于-std=gnu90,它是1989/1990标准,具有特定于GNU的扩展名. (未发布语言标准要求的某些诊断.)2015年4月22日发布的版本5.1.0将默认设置从-std=gnu90更改为-std=gnu11,即

By default, gcc does not conform to any of the ANSI/ISO C standards. The current default is equivalent to -std=gnu90, which is the 1989/1990 standard with GNU-specific extensions. (Some diagnostics required by the language standard are not issued.) Version 5.1.0, released 2015-04-22, changed the default from -std=gnu90 to -std=gnu11, as documented here.

如果要符合标准,可以使用以下任何一种方法:

If you want standard conformance, you can use any of the following:

-std=c90 -pedantic
-std=c99 -pedantic
-std=c11 -pedantic

-std=c90也可以拼写为-ansi-std=c89-std=iso9899:1990.

-std=iso9899:199409支持C90标准以及1995年修订版,该修订版增加了一些次要功能(所有功能也在C99中).

-std=iso9899:199409 supports the C90 standard plus the 1995 amendment, which added a few minor features (all of which are also in C99).

-std=c99也可以拼写为-std=c9x-std=iso9899:1999(在发布标准之前使用名称c9x). C99支持不太完善,但是已经很接近了.

-std=c99 can also be spelled -std=c9x or -std=iso9899:1999 (the name c9x was used before the standard was published). C99 support is not quite complete, but it's close.

-std=c11也可以拼写为-std=c0x-std=iso9899:2011(在发布最终标准之前使用名称c0x;错误地认为x不会超过9). C11支持也不完整;当前状态为在此处总结.

-std=c11 can also be spelled -std=c0x or -std=iso9899:2011 (the name c0x was used before the final standard was published; it was wrongly assumed that x would not exceed 9). C11 support is also incomplete; the current status is summarized here.

-pedantic选项使gcc打印所需的诊断信息,以检查是否违反约束和语法规则.在某些情况下,这些诊断仅是警告-并没有容易的方法来区分这些警告和该语言不需要的其他警告.将-pedantic替换为-pedantic-errors,以使gcc将违反语言的行为视为致命错误.

The -pedantic option causes gcc to print required diagnostics for violations of constraints and syntax rules. In some cases, those diagnostics are merely warnings -- and there's no easy way to distinguish between those warnings and other warnings that aren't required by the language. Replace -pedantic by -pedantic-errors to cause gcc to treat language violations as fatal errors.

标准的简要记录:

  • C89是第一个正式的C标准,由 ANSI 在1989年发布.
  • C90是该标准的 ISO 版本,描述的语言与C89完全相同. ANSI正式采用了该标准的ISO版本.有两个技术勘误,更正了一些错误.
  • C95是对C90的修订,增加了一些功能,主要是有向图和广泛的字符支持.据我所知,从未发布过合并版本.
  • C99由ISO于1999年发布.共有三个技术勘误.
  • C11是ISO于2011年发布的.存在一项技术勘误,其中固定了__STDC_VERSION____STDC_LIB_EXT1__的定义.
  • C89 was the first official C standard, published by ANSI in 1989.
  • C90 was the ISO version of the standard, describing exactly the same language as C89. ANSI officially adopted ISO's version of the standard. There were two Technical Corrigenda, correcting some errors.
  • C95 was an amendment to C90, adding a few features, mainly digraphs and wide character support. As far as I know, a merged version was never published.
  • C99 was issued by ISO in 1999. There were three Technical Corrigenda.
  • C11 was issued by ISO in 2011. There has been one Technical Corrigendum, fixing the definitions of __STDC_VERSION__ and __STDC_LIB_EXT1__.

ANSI没有发布自己的1999或2011标准版本,而是采用了ISO标准.

ANSI did not issue its own versions of the 1999 or 2011 standards, adopting the ISO standards instead.

N1256 是免费提供的草案C99标准,并合并了3个技术勘误.

N1256 is a freely available draft of the C99 standard, with the 3 Technical Corrigenda merged into it.

N1570 是免费提供的草案符合C11标准.它与已发布的C11标准之间存在一些细微差异,外加一项技术勘误.有关更多详细信息,请参见我的答案. >这个问题.

N1570 is a freely available draft of the C11 standard. There are some minor differences between it and the published C11 standard, plus one Technical Corrigendum. For more details, see my answer to this question.

这篇关于当前GCC的默认C -std标准版本是什么(尤其是在Ubuntu上)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆