C语言 GNU99 和 C99 (Clang) 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5313536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 08:04:14  来源:igfitidea点击:

What's the difference between GNU99 and C99 (Clang)?

ccompiler-constructionoptionclang

提问by Eonil

I have saw the compiler option GNU99 and C99. What's the difference of them? Any detail documentation? (Clang, Xcode, Mac OS X)

我已经看到编译器选项 GNU99 和 C99。它们有什么区别?有详细的文档吗?(Clang、Xcode、Mac OS X)

采纳答案by Matt Joiner

Differences between various standard modes

各种标准模式的区别

clang supports the -std option, which changes what language mode clang uses. The supported modes for C are c89, gnu89, c94, c99, gnu99 and various aliases for those modes. If no -std option is specified, clang defaults to gnu99 mode.

Differences between all c* and gnu* modes:

  • c* modes define __STRICT_ANSI__.
  • Target-specific defines not prefixed by underscores, like "linux", are defined in gnu* modes.
  • Trigraphs default to being off in gnu* modes; they can be enabled by the -trigraphsoption.
  • The parser recognizes "asm" and "typeof" as keywords in gnu* modes; the variants __asm__and __typeof__are recognized in all modes.
  • The Apple "blocks" extension is recognized by default in gnu* modes on some platforms; it can be enabled in any mode with the -fblocksoption.

clang 支持 -std 选项,它改变了 clang 使用的语言模式。C 支持的模式是 c89、gnu89、c94、c99、gnu99 以及这些模式的各种别名。如果未指定 -std 选项,clang 默认为 gnu99 模式。

所有 c* 和 gnu* 模式之间的差异:

  • c* 模式定义__STRICT_ANSI__.
  • 没有下划线前缀的特定于目标的定义,如“linux”,在 gnu* 模式中定义。
  • Trigraphs 在 gnu* 模式下默认关闭;它们可以通过-trigraphs选项启用。
  • 解析器将 "asm" 和 "typeof" 识别为 gnu* 模式中的关键字;变体__asm____typeof__在所有模式下都能识别。
  • 在某些平台上的 gnu* 模式下,Apple“blocks”扩展默认被识别;它可以在任何模式下使用该-fblocks选项启用。

More links

更多链接

回答by Paul R

C99 is straight C99, GNU99 is C99 with gnu extensions. See the GCC manpage.

C99 是直接的 C99,GNU99 是带有 gnu 扩展的 C99。请参阅GCC 联机帮助页

回答by Paul R

C99 is simply the version of the C standard as of 1999 as we all know it. In GCC it is not fully supported.

众所周知,C99 只是 1999 年的 C 标准版本。在 GCC 中,它不受完全支持。

GNU99 is an extension to C99, just like GNU98 is an extension of C98. From the docs:

GNU99 是 C99 的扩展,就像 GNU98 是 C98 的扩展一样。从文档:

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

ISO C99 加上 GNU 扩展。当 ISO C99 在 GCC 中完全实现时,这将成为默认设置。名称 gnu9x 已弃用。

Clang supports these extensions also.

Clang 也支持这些扩展。