Different Standards of C language

First of all we need to understand, what is the standard or specification of any programming language?

The standard for any programming language is a documentation artifact that defines some consistent rules so that programmers can agree on what programs in that language mean.

Now the question arises, who will be responsible for language specification or standard?

The C standards committee is responsible for making these rules or any changes regarding C standardisation is called ISO/IEC JTC 1/SC 22/WG 14.

It is an  international standardization  joint technical working group ISO/IEC JTC 1 of the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) for the C programming language.

The C was developed by Dennis M Ritchie and his team between 1969 and 1972 at Bell laboratories. It was accepted by almost all the programmers immediately, and they started making their own versions to it.

Few years later, there were a lot of C versions available for a programmer to choose from.

My C instruction set was different from yours, and nobody could claim that theirs was the real one. So, there was a need for specification and the masters themselves have undertaken the task.

There are some standard for c language, which are given below:

K&R C

The standard K&R C was actually an informal specification based on the first edition of the book, ‘The C Programming Language’, by Brian Kernighan and Dennis Ritchie published in 1978. The book was so popular that the language came to be known as “K&R C” among the programming community.

The K&R C standard added many features such as new datatypes unsigned int and  long int and the compound assignment operator in it. According to K&R C, there were 28 keywords in it. One keyword named as entry, which was never used at that time by any of the compilers. The standard IO library proposed by K&R C.

ANSI C (C89)

Even though K&R C was accepted by almost all professional programmers as the de facto standard of C, it was not the de jure standard, and everyone accepted it as an official standard of language. So, it was absolutely essential that some standard organisation officialize the C language standard.

To ensure that C language remains standard, in 1983 American national standard institute(ANSI) appointed a technical committee to define an official standard for C language. The committee approved a version of C in December 1989, which is known as ANSI C. It was then approved by the International standards organization (ISO), so this is the reason why ANSI C is also known as C89. It is dependent on the POSIX standard.

According to ANSI C, there were 32 keywords in it. The five keywords volatile, enum, const, void and signed were added, and the keyword entry was removed from ANSI C. The option -ansi of gcc compiler, -std=c89 and -std=c90 will compile the program in the ANSI C standard.

Syntax for compilation in C89 or ANSI C -:

gcc -std=c89 filename.c

The ANSI C or C89 was modified in 1990 by the International Standard Organization(ISO) as ISO/IEC 9899:1990, with only formatting changes. So there is no major difference between c89 and c90, but later this standard has been withdrawn by ANSI/INCITS and ISO/IEC.

In 1995, ISO made some changes such as specification of standard macros for the alternative specification of operators; e.g and for &&, addition of digraphs and improved multi bytes and wide char support in standard library. This version of C is also called as c95.

Almost all the compiler supports ANSI C.

GCC and Clang are major compilers which are used nowadays.

C99

In 2000, ANSI released ISO/IEC 9899:1999 standard for the C language. This standard of C is commonly referred to as C99.

There are five more keywords added to the previous keyword set of ANSI C. The C99 added keywords which are  _Bool, _Complex, _Imaginary, inline and restrict in ANSI C.

The _Bool keyword is used to declare an integer which is capable of storing  0 and 1.

The _Imaginary and _Complex used to declare complex and imaginary which are capable of storing floating point complex numbers. They only work with double, float and long double.

The restrict keyword in C is used to declare a pointer. Through the restrict keyword the compiler got to know that for the lifetime of a pointer, only the pointer itself or a value directly derived from it will be used to access the object to which it points.

The inline keyword is used to declare inline functions in C programming, just like C++ inline functions. So, the total number of keywords in c99 are 37.

New header files like <stdint.h>, <stdbool.h>, <tgmath.h>, <complex.h>, <inttypes.h> and <fenv.h> etc. were also added to the c99.

One more integer data type long long int was added to the c99. The c99 improved single-line comments with //, mixing declarations and universal character names in identifiers and removed some previous features such as implicit function declaration and implicit int.

The gcc and clang compiler supports almost all the features proposed by official c99.

Syntax for compilation in C99  -:

gcc -std=c89 filename.c

C11

In 2011, ANSI released ISO/IEC 9899:2011 standard for the C language. It is commonly referred to as c11.

The C11 has 44 keywords in it. Starting 32 keywords of C11 is taken from ANSI C and 5 keywords from C99 which we have already discussed. There are 7 more keywords added to the C language, which are _Noreturn, _Generic, _Atomic, _Alignof_Static_assert, _Alignas and  _Thread_local.

  • It includes a detailed memory model to better support multiple threads or multithreading  of execution.
  • It has improved Unicode support.
  • Length of arrays are optional in c11.
  • Header file <stdnoreturn.h> is added to the c11.
  • Concurrent programming is supported by c11.
  • gets( ) library function is removed from c11.
  • A new timespec_get( ) function and corresponding structure in <time.h> with a degree of POSIX compatibility.
  • A standard macro __STDC_VERSION__ is defined with value 201112L to indicate that C11 support is available.

Syntax for compilation in C11  -:

gcc  -std=c11 filename.c

Note: In 2018, the C language is again updated and known as c18. C18 addressed defects in C11 without introducing new language features, so there are no new major changes in c18 and  we can say that c11 and c18 are the same. The only change in c18 was __STDC_VERSION__ macro is increased  to the value 201710L.

Note: C18 is the current and latest standard of the C language and, as the name suggests, this standard was adopted in 2018.