What is the difference between C, C99, ANSI C and GNU C?

余生颓废 提交于 2019-11-26 06:04:04

问题


I have started programming practice on codechef and 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.

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?

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?

EDIT:

This, This, This helped. 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.


回答1:


  • 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_assert and 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.


"C99 strict" likely refers to a compiler setting forcing a compiler to follow the standard by the letter. There is a term conforming implementation in 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.

"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.c then 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.

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.




回答2:


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.




回答3:


  • 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 is a standard which is being used by or refereed the other standards.




回答4:


In Addition To Lundin Answer

Here is What Dennis Richie Has To Say When Asked

"Why didn't K&R wait for the final, approved ANSI standard before writing K&R 2nd edition?"

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




回答5:


This question was not thoroughly searched on net for answer ,anyway you may look at this :

  1. C is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs.
  2. C99 is a standard of the C language published by ISO and adopted by ANSI in around 1999.
  3. 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=c99 which is already mentioned in the other answers.
  4. ANSI C is a successive series of standards released by ANSI.


来源:https://stackoverflow.com/questions/17206568/what-is-the-difference-between-c-c99-ansi-c-and-gnu-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!