C语言 C、C99、ANSI C 和 GNU C 之间有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17206568/
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
What is the difference between C, C99, ANSI C and GNU C?
提问by Aseem Bansal
I have started programming practice on codechefand have been confused by the difference between C and C99. What does C mean here? Is it C89?Check the languages at the bottom of this submit. It contains both C and C99.
我已经开始在codechef上进行编程练习,并且对C 和 C99 之间的差异感到困惑。C在这里是什么意思?是C89吗?检查此提交底部的语言。它包含 C 和 C99。
I found on the internet something called GNU C. Is there a different C for linux/unix systems? Are these compliant to the C standards by ANSI? I have also read in some places "C99 strict". What is this?
我在互联网上找到了一个叫做 GNU C 的东西。 linux/unix 系统有没有不同的 C?这些是否符合 ANSI 的 C 标准?我也在一些地方读过“C99严格”。这是什么?
Are there any other different standards of C in use? Is there something called C 4.3.2 or is it the gcc version in current use?
是否还有其他不同的 C 标准在使用?有没有叫做 C 4.3.2 的东西,还是当前使用的 gcc 版本?
EDIT:
编辑:
This, This, Thishelped. I'll search more and edit the things that are left unanswered.
I am not a programming newbie. I know what C language is. I know that there are the different C standards by ANSI like C89, C99 and C11.
我不是编程新手。我知道什么是C语言。我知道 ANSI 有不同的 C 标准,如 C89、C99 和 C11。
回答by Lundin
Everything before standardization is generally called "K&R C", after the famous book, with Dennis Ritchie, the inventor of the C language, as one of the authors. This was "the C language" from 1972-1989.
The first C standard was released 1989 nationally in USA, by their national standard institute ANSI. This release is called C89 or ANSI-C. From 1989-1990 this was "the C language".
The year after, the American standard was accepted internationally and published by ISO (ISO 9899:1990). This release is called C90. Technically, it is the same standard as C89/ANSI-C. Formally, it replaced C89/ANSI-C, making them obsolete. From 1990-1999, C90 was "the C language".
Please note that since 1989, ANSI haven't had anything to do with the C language. Programmers still speaking about "ANSI C" generally haven't got a clue about what it means. ISO "owns" the C language, through the standard ISO 9899.
A minor update was released in 1995, sometimes referred to as "C95". This was not a major revision, but rather a technical amendment formally named ISO/IEC 9899:1990/Amd.1:1995. The main change was introduction of wide character support.
In 1999, the C standard went through a major revision (ISO 9899:1999). This version of the standard is called C99. From 1999-2011, this was "the C language".
In 2011, the C standard was changed again (ISO 9899:2011). This version is called C11. Various new features like
_Generic,_Static_assertand thread support were added to the language. The update had a lot of focus on multi-core, multi-processing and expression sequencing. From 2011-2017, this was "the C language".In 2017, C11 was revised and various defect reports were solved. This standard is informally called C17 and was released as ISO 9899:2018. It contains no new features, just corrections. It is the current version of the C language.
标准化之前的一切一般都被称为“K&R C”,以著名的书命名,C语言的发明者丹尼斯·里奇(Dennis Ritchie)是作者之一。这就是 1972-1989 年的“C 语言”。
第一个 C 标准于 1989 年在美国全国发布,由其国家标准机构 ANSI 发布。此版本称为 C89 或 ANSI-C。从 1989 年到 1990 年,这是“C 语言”。
次年,美国标准被国际接受并由 ISO (ISO 9899:1990) 发布。此版本称为 C90。从技术上讲,它与 C89/ANSI-C 的标准相同。正式地,它取代了 C89/ANSI-C,使它们过时了。从 1990 年到 1999 年,C90 是“C 语言”。
请注意,自 1989 年以来,ANSI 与 C 语言没有任何关系。仍在谈论“ANSI C”的程序员通常不知道它的含义。ISO 通过标准 ISO 9899“拥有”C 语言。
1995 年发布了一个小更新,有时称为“C95”。这不是重大修订,而是正式命名为 ISO/IEC 9899:1990/Amd.1:1995 的技术修订。主要的变化是引入了广泛的字符支持。
1999 年,C 标准进行了重大修订(ISO 9899:1999)。该版本的标准称为 C99。从 1999 年到 2011 年,这是“C 语言”。
2011 年,C 标准再次更改(ISO 9899:2011)。此版本称为 C11。各种新功能,如
_Generic,_Static_assert和线程支持添加的语言。该更新非常关注多核、多处理和表达排序。从 2011 年到 2017 年,这是“C 语言”。2017年修订C11,解决各种缺陷报告。该标准非正式地称为 C17,并作为 ISO 9899:2018 发布。它不包含任何新功能,只是更正。它是 C 语言的当前版本。
"C99 strict" likely refers to a compiler setting forcing a compiler to follow the standard by the letter. There is a term conforming implementationin the C standard. Essentially it means: "this compiler actually implements the C language correctly". Programs that implement the C language correctly are formally called strictly conforming programs.
“C99 严格”可能是指编译器设置强制编译器通过字母遵循标准。在 C 标准中有一个术语符合实现。本质上它的意思是:“这个编译器实际上正确地实现了 C 语言”。正确实现 C 语言的程序正式称为严格符合程序。
"GNU C" can mean two things. Either the C compiler itself that comes as part of the GNU Compiler Collection (GCC). Or it can mean the non-standard default setup that the GCC C compiler uses. If you compile with gcc program.cthen you don't compile according to the C standard, but rather a non-standard GNU setup, which may be referred to as "GNU C". For example, the whole Linux kernel is made in non-standard GNU C, and not in standard C.
“GNU C”可能意味着两件事。作为 GNU 编译器集合 (GCC) 的一部分的 C 编译器本身。或者它可能意味着 GCC C 编译器使用的非标准默认设置。如果你用它编译,gcc program.c那么你不是根据 C 标准编译,而是根据非标准 GNU 设置,它可能被称为“GNU C”。例如,整个 Linux 内核是用非标准的 GNU C 编写的,而不是用标准的 C 编写的。
If you want to compile your programs according to the C standard, you should type gcc -std=c99 -pedantic-errors. Replace c99 with c11 if your GCC version supports it.
如果你想按照 C 标准编译你的程序,你应该输入gcc -std=c99 -pedantic-errors. 如果您的 GCC 版本支持 c11,请将 c99 替换为 c11。
回答by C Is Better
I MUST respond regarding ANSI C. Although ANSI has not done anything with it, compilers are still built to it. PIC XC16 compiler for example: "The compiler is a fully validated compiler that conforms to the ANSI C standard as defined by the ANSI specification (ANSI x3.159-1989) and described in Kernighan and Ritchie's The C Programming Language (second edition). ..." Not all programming is for "big" computers like PCs. Writing a compiler for your device costs, and validating costs time & $. ANSI C is alive & well & living in your embedded / real-time devices.
我必须对 ANSI C 做出回应。虽然 ANSI 没有对它做任何事情,但编译器仍然是针对它构建的。例如,PIC XC16 编译器:“该编译器是经过充分验证的编译器,符合 ANSI 规范 (ANSI x3.159-1989) 定义并在 Kernighan 和 Ritchie 的 The C Programming Language(第二版)中描述的 ANSI C 标准。 ...”并非所有编程都适用于像 PC 这样的“大型”计算机。为您的设备成本编写编译器,并验证成本时间 & 美元。ANSI C 在您的嵌入式 / 实时设备中还很活跃。
回答by Kapil Chittewan
ANSI C : The first C language was standardized by the body called ANSI in 1989 that's why it is called c89.
C99 :
with the demand from the developers requirements, in 1999-2000 further or additional keywords and features have been included in C99 (ex: inline, boolean.. Added floating point arthematic library functions)GNU C: GNU is a unix like operating system (www.gnu.org) & somewhere GNU's project needs C programming language based on ANSI C standard. GNU use GCC (GNU Compiler Collection) compiler to compile the code. It has C library function which defines system calls such as malloc, calloc, exit...etc
ANSI C:第一个 C 语言在 1989 年被称为 ANSI 的机构标准化,这就是它被称为 c89 的原因。
C99 :
应开发者的要求,在1999-2000年进一步或附加的关键字和特性已包含在C99中(例如:inline、boolean..添加了浮点数学库函数)GNU C:GNU 是一个类似 unix 的操作系统(www.gnu.org),在某些地方 GNU 的项目需要基于 ANSI C 标准的 C 编程语言。GNU 使用 GCC(GNU Compiler Collection)编译器来编译代码。它有 C 库函数,定义系统调用,如 malloc、calloc、exit...等
ANSI C is a standard which is being used by or refereed the other standards.
ANSI C 是其他标准正在使用或参考的标准。
回答by Suraj Jain
In Addition To Lundin Answer
除了伦丁回答
Here is What Dennis Richie Has To SayWhen Asked
这是丹尼斯·里奇 (Dennis Richie) 在被问到时必须说的话
"Why didn't K&R wait for the final, approved ANSI standard before writing K&R 2nd edition?"
“为什么 K&R 在编写 K&R 第二版之前不等待最终的、批准的 ANSI 标准?”
Why didn't K&R wait for the final, approved ANSI standard before writing K&R 2nd edition? It seems like this book will only be the correct standard for a few months before it will be supesceded by the final ANSI standard. I know that there are likely to be few major changes at this late stage, but why not wait a few months and make sure you get it 100% right, rather than needing to almost immediately write a 3rd edition or be obsolete?
We thought it would be nice to mark the 10th anniversary of the first edition. More seriously, we started work last summer because we had the time and inclination then, and it appeared that X3J11 was approaching an end. In December and January, as we were finishing, we considered whether the possibility of important changes warranted putting off delivery, and (after discussing the matter with the publisher) decided that it was not worth waiting. P-H wanted it, and both Brian and I wanted it off our agendas.
Even if there are changes in the standard, it's hard to imagine that they would be extensive enough to warrant a new edition. (We were even prepared to cope somehow with noalias, if it had lasted.) We're ready to make necessary changes in a future printing, but there's reason to hope that they should be minor. X3J11's members are very anxious to finish without surprising people, too; many of them work for companies that are preparing ANSI compilers, after all.
Dennis Ritchie
为什么 K&R 在编写 K&R 第二版之前不等待最终的、批准的 ANSI 标准?看起来这本书只会在几个月内成为正确的标准,然后才会被最终的 ANSI 标准取代。我知道在这个后期阶段可能很少有重大变化,但为什么不等几个月并确保您 100% 正确,而不是几乎需要立即编写第 3 版或过时?
我们认为纪念第一版 10 周年会很好。更严重的是,我们去年夏天开始工作,因为我们当时有时间和兴趣,看起来X3J11已经接近尾声了。在 12 月和 1 月,当我们完成时,我们考虑了是否有必要推迟交付重要更改的可能性,并且(在与出版商讨论此事后)决定不值得等待。PH 想要它,Brian 和我都希望它不在我们的议程上。
即使标准发生了变化,也很难想象它们会足够广泛以保证新版本。(我们甚至准备以某种方式应对 noalias,如果它持续存在。)我们准备在未来的印刷中进行必要的更改,但有理由希望它们应该是次要的。X3J11的成员们也很着急,想要在不让人意外的情况下完成;毕竟,他们中的许多人为准备 ANSI 编译器的公司工作。
丹尼斯·里奇
回答by 0decimal0
This question was not thoroughly searched on net for answer ,anyway you may look at this :
这个问题没有在网上彻底搜索过答案,无论如何你可以看看这个:
- C is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs.
- C99 is a standard of the C language published by ISO and adopted by ANSI in around 1999.
- GNU C is just an extension of c89,while some features of c99 are also added,but in entirety it is different from c99 standard so when compiling in gcc we have to enter
-std=c99which is already mentioned in the other answers. - ANSI C is a successive series of standards released by ANSI.
- C 是一种通用编程语言,最初由丹尼斯·里奇 (Dennis Ritchie) 于 1969 年至 1973 年间在 AT&T 贝尔实验室开发。
- C99是ISO发布的C语言标准,1999年左右被ANSI采用。
- GNU C只是c89的扩展,同时也增加了c99的一些特性,但总体上它与c99标准不同,所以在gcc中编译时我们必须输入
-std=c99其他答案中已经提到的。 - ANSI C 是 ANSI 发布的一系列标准。

