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

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

问题描述

当我要求查看 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 或在线 这里.4.7.2 手册的相关部分是这里.

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-04-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=c90 can also be spelled -ansi, -std=c89, or -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 于 1999 年由 ISO 发布.共有三个技术勘误表.
  • C11 于 2011 年由 ISO 发布.有一次技术勘误,修正了__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(尤其是在 Ubuntu 上)的默认 C -std 标准版本是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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