Variants of the programming language C
Several variants (specifications and international standards) have been published since the appearance of the C programming language in 1972 .
K & R-C
With K & R C, the C variant is referred to as original by the inventors Brian Kernighan and Dennis Ritchie was written and in the first edition of her book The C Programming Language 1978 (K & R1) is described.
X / Open-C
Standardization efforts by X / Open Company, Ltd. about the standardization of C for the purpose of interoperability of different Unix versions in 1987. Most of the extensions and specifications were adopted in C89.
C89, C90
In 1983 the American National Standards Institute (ANSI) formed a committee called X3J11 to develop a standard for the C programming language. The programming language C, as conceived by the inventors Brian W. Kernighan and Dennis Ritchie ( K & R-C ), served as the basis for the language definition .
After six years of work, the ANSI X3.159-1989 Programming Language C standard was adopted in December 1989 . This version of the C language is also known as C89 because of the year it was published . A year later, in 1990, this standard was adopted (with a few minor changes) by ISO's WG14 as ISO / IEC 9899: 1990 ( C90 ). The revised second edition of The C Programming Language from 1988 (K & R2) reflects the changes to the language through the standardization process.
Many of the previously unstandardized properties of the language have been standardized, but new language resources such as function prototypes , a more powerful C preprocessor , and the possibility of declaring constants have also been included in the language. Among other things, the C standard cleared up ambiguities in the original definition, including the execution order of the four increment and decrement operators ( ++
, --
). The standard also specified the scope of the standard library included .
To this day, C90 is the language base for all further developments of the C programming language, including for C ++ , which has options for object-oriented and generic programming.
A program based on C90 should be able to be compiled and executed by any C compiler without problems . In practice, this is only partially the case, since almost all C derivatives use additional libraries and function prototypes in order to be able to access the individual components of the computer system.
The terms ANSI C, C89 and ISO C90 are equivalent.
To this day (as of 2020), C89 is still very much used. For example, cURL , SQLite and libxml2 are all written in C89.
Innovations of the C90
- The range of functions and the behavior of the functions of the standard library have been standardized.
- An improved preprocessor was introduced.
- Function prototypes were introduced.
-
void
for empty function parameter declarations and for marking functions without a return value as well asvoid*
for a universally compatible pointer type were added. - The new keywords
const
,volatile
andsigned
have been introduced. - The unused keyword
entry
has been removed. - Support for wide-character (more than 8 bits wide) and multibyte character sets has been added.
Preprocessor test for C90 compatibility
#if __STDC__
/*
* C90-kompatibler Quellcode.
*/
#endif
C95
In 1995 the ISO published an extension - Amendment 1 - to the C standard, which was then referred to as ISO / IEC 9899 / AMD1: 1995 (C95) . In addition to bug fixes, there were also changes to the scope of the language.
Innovations from C95
- Improvement of the support of multibyte and wide-character character sets by the standard library.
- Adding digraphs to the language.
- Definition of standard macros for alternative notation of operators, for example
and
for&&
. - Definition of the standard macro
__STDC_VERSION__
.
Preprocessor test for C95 compatibility
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199409L
/*
* C95-kompatibler Quellcode.
*/
#endif
C99
In 1995 another committee was established to expand and improve C. In 1999, this resulted in the new ISO standard ISO / IEC 9899: 1999 , also known as C99 . It replaced the ISO / IEC 9899: 1994-09 (C95) standard . A Technical Corrigendum 1 was published for this standard in 2001 , a Technical Corrigendum 2 in 2004 and a Technical Corrigendum 3 in 2007 . In the meantime, all Corrigenda have been summarized in a new edition of ISO / IEC 9899: 2018 from June 2018. C99 including these corrections is also unofficially referred to as C0X and forms the basis for future C standards.
With C99, some extensions known from C ++ flowed into the C language, for example inline functions and the possibility of declaring variables within the for
instruction .
Innovations of C99
- Support of complex numbers through the new data type
_Complex
and corresponding functions in the standard library. - compound literals.
- Certain initializers.
- Extension of the integer data types by a type
long long
with a width of at least 64 bits , as well as types with a specified minimum width, for exampleint_least8_t
anduint_least32_t
. In addition, exact-width integer types are specified, but designated as optional - for exampleint32_t
. - Fields of variable size (so-called variable length arrays ).
- The Boolean data type
_Bool
.<stdbool.h>
An alias namebool
and the valuestrue
and arefalse
defined for it via a separate header . - Further improved support for international character sets.
- Extended support for floating point numbers including new mathematical functions in the C library.
-
Alias -free pointers (keyword
restrict
). - Freely placeable declaration of identifiers (in C90 these could only be at the beginning of a block).
- Inline functions (keyword
inline
). - Prohibition of the "implicit
int
"; Prohibition of implicit function declarations. - Hexadecimal floating point constants. Input and output in
scanf()
andprintf()
via "%a
" and "%A
". - Preprocessor macros with a variable number of parameters.
- Allow the line comment "
//
" known from C ++ . - Possibility of a declaration in the first expression of a for loop:
for(int i=0;...)
Preprocessor test for C99 compatibility
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
// Compiler ist C99-kompatibel.
#endif
C11
The WG14 standardization committee worked on a new edition of the C standard with the working title C1X , based on the C99 standard including the Technical Corrigenda TC1, TC2 and TC3 (C0X) . On December 8, 2011, C11 was adopted as ISO / IEC 9899: 2011.
Innovations of C11
The list is based on various technical reports and the current working document on C1X.
- Multithreading support (
<threads.h>
,<stdatomic.h>
) - Information on the memory alignment of objects (
<stdalign.h>
) - New data types
char16_t
andchar32_t
improved support for Unicode , especially UTF-16 and UTF-32 (<uchar.h>
) - Changes to the standard library for checking field boundaries at runtime of the program, e.g. B. to avoid buffer overflows more effectively
- Support of the internal decimal representation of floating point numbers according to IEEE 754-2008
- Opening files with exclusive read / write rights (mode "x")
- Generic Expressions (Keyword
_Generic
), Generic Math Functions for Floating Point Numbers and Complex Numbers (<tgmath.h>
) - Removal of the library function
gets
- Some of the functionalities required in C99 are released to compiler manufacturers in C11, such as B. Local fields of variable size, complex numbers. The range of functions can be queried with the help of compiler defines:
__STDC_NO_COMPLEX__
(no complex numbers),__STDC_NO_VLA
(no fields of variable length)
Preprocessor test for C11 compatibility
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
// C11 kompatibler Quellcode.
#endif
C18
This standard corresponds to that of C11 with the exception of error corrections and a new value of __STDC_VERSION__ and is therefore supported to the same extent as C11. The standard was established in June 2018 under the standard ISO / IEC 9899: 2018 released
Examples of the difference between different versions of the C language
K & R-C:
/* Es gibt noch keine Funktionsprototypen. */
Ausgabe(str)
char *str;
{
printf("%s\n", str);
}
main()
{
Ausgabe("Hallo Welt!");
return 0;
}
C90 / C95:
#include <stdio.h>
/* Das Argument darf nicht geändert werden. */
void Ausgabe(const char * const str) {
printf("%s\n", str);
}
main() {
Ausgabe("Hallo Welt!");
return 0;
}
C99 / C11:
#include <stdio.h>
void Ausgabe(char *str) {
printf("%s\n", str);
}
int main() {
Ausgabe("Hallo Welt!");
}
Web links
- Dennis M. Ritchie: The Development of the C Language. Retrieved September 12, 2010 .
- C89 Draft ( Memento from February 7, 2005 in the Internet Archive )
- Rationale for C89. Retrieved September 12, 2010 .
- ISO / IEC 9899: 1999 (C99) with TC1, TC2 and TC3. (PDF; 3.8 MB) Accessed on September 12, 2010 (English, non-normative working document).
- Rationale for C99, revision 5.10. (PDF; 898 kB) Accessed September 12, 2010 (English).
- List of compilers with information on C99 compliance. Retrieved October 7, 2010 .
- ISO / IEC C11 final working draft (PDF)
- Chronology standardization (English)
- Draft for ISO / IEC 9899: 2018 from November 1, 2017
Individual evidence
- ↑ Clive DW Feather: A brief description of Normative Addendum 1. Accessed September 12, 2010 .
- ↑ ISO / IEC 9899: 1990 / Amd 1: 1995. International Organization for Standardization, accessed March 22, 2013 .
- ↑ C99 Technical Corrigendum 1. (PDF; 21 kB) Retrieved on September 22, 2010 (English).
- ↑ C99 Technical Corrigendum 2. (PDF; 353 kB) Retrieved on September 22, 2010 (English).
- ↑ C99 Technical Corrigendum 3. (PDF; 0 kB) (No longer available online.) Archived from the original on July 7, 2009 ; accessed on September 22, 2010 (English).
- ↑ ISO / IEC Technical Committee: Last revision 'ISO / IEC 9899: 2018'. June 2018, accessed December 15, 2019 .
- ^ John Benito: Official charter for the C1X standardization process. (PDF; 49 kB) Retrieved September 12, 2010 (English).
- ↑ ISO updates C standard. Retrieved December 23, 2011 .
- ↑ Article from heise online. Retrieved December 23, 2011 .
- ↑ Project status for C1X. Retrieved September 12, 2010 .
- ↑ ISO / IEC 9899: 201x. (PDF; 1.6 MB) Accessed April 12, 2011 (English, non-normative working document).
- ^ Extensions to the C Library, Part I: Bounds-checking interfaces. (PDF; 565 kB) Accessed October 31, 2010 (English, draft).
- ↑ Options Controlling C Dialect. Retrieved September 8, 2018 .
- ↑ ISO / IEC 9899: 2018 Programming languages C. Retrieved September 8, 2018 .