C - Standards (ANSI, ISO, C99, C11, C17)



A programming language standard is typically a set of specifications that precisely define the programming language syntax and semantics (i.e., the rule of writing the code, what the code means and how it behaves when executed).

The C programming language standard defines the behavior of the program, i.e., How the program will ideally run? What are the correct ways and definitions of some in-built functions? The standard works as a definitive "contract" between the programmers and the language implementers to ensure a certain level of consistency on how a language should work across different software.

Standardized Versions of C Programming Language

Some of the most commonly used C Standards are listed below −

  • C89 / ANSI C (1989) - C90 (ISO 1990) − It was the first standardized versions of the C language. In this, version new features were added such as function prototypes, standard library, const, volatile, enum.
  • C95 Amendment − Introduced wide character library (h) for better support of international character sets, and provided iso646.h to provide alternative spellings for C operators (like and, or, not) to improve code readability and portability.
  • C99 (1999) − Introduced several new features lncluded long long int, stdbool.h, variable length arrays, flexible array members, inline functions, complex numbers, and // comments.
  • C11 (2011) − It introduced several new features including _Generic, static_assert, and the atomic type qualifier <stdatomic.h>, also addition of multithreading <threads.h>, Unicode (char16_t, char32_t) and memory manipulation.
  • C17 (2017/2018) − In this version, only bug fixes to C11, no new features were added.
  • C18 (2018) − Maintenance release, identical to C17 in practice.
  • C23 (latest) − It is the latest version of C that better supports the const qualifier and addition of the new keywords, attributes, typeof, improved Unicode, and contracts.

The following table compares and contrasts the important features of different C standards −

Features K&R C C89/C90 C99 C11 C17/C18 C23
Function Prototype No Yes Yes Yes Yes Yes
// Comments No No Yes Yes Yes Yes
Long long int No No Yes Yes Yes Yes
Multithreading No No No Yes Yes Yes
Atomics No No No Yes Yes Yes
Unicode Support No No Limited Yes Yes Yes

Advantages of Having Standards in Programming Languages

It is important to have Standards because they ensure uniformity in Syntax and Semantics, and reduce ambiguity by promoting consistency in any programming language −

  • Syntax − The grammatical rules that make a meaning and create valid programs by combining the statement keywords and symbols.
  • Semantics − Semantics are the set of rules that determines the meaning and execution behavior of the code written in the language. This includes the control flow of the programs how data is processed, and how memory is managed.
  • Consistency − The standard makes sure that different compilers and interpreters for the same language give consistent results, making code more portable and predictable.
  • Ambiguity Reduction − Ambiguity is something that can be understood in more than one way. In the C programming language, where the compiler cannot uniquely identify which specific identity (like a function, variable, or member) is being referred to due to multiple possible interpretations, it is ambiguity.

By providing precise definition and standards, which minimize ambiguities and undefined behavior, one can avoid different interpretations or errors when running the code.

Role of ANSI and ISO in C standardization

In the early days (k&R C), different compilers (AT&T, DEC, HP, etc.) implemented their own versions of C. It caused incompatibility: a program written for one compiler often would not compile and behave the same way on another. Therefore, C needed a formal standard to ensure that a program would have portability, reliability, and consistency.

ANSI’s Role (American National Standards Institute)

ANSI formed the X3J11 committee in 1983 to develop the standard specification for the C language. After the Several years of work they published C89 (ANSI C in 1989). After the development of C89 the ANSI C become the foundation on which all future was built.

Following is the key contribution of the ANCI C (C89):

  • Defined function prototypes and type checking.
  • Introduced const, volatile, signed, and void
  • Standardized the C Standard Library (h, stdlib.h, string.h, etc.).
  • Removed ambiguities from K&R C, making C more portable.

ISO’s Role (International Organization for Standardization)

The standard was submitted to the ISO/IEC JTC1/SC22/WG14 committee after the ANSI published C89. So, ISO adopted ANSI C in 1990, with the minor changes known as C90.

ISO became the prime authority responsible for maintaining and revising the C language standard (C95, C99, C11, C17, C18, C23). ISO ensures that the standard is globally recognized, so C remain platform-independent and works with a wide range of compilers and operating systems.

Relationship between ANSI and ISO

ANSI is a national standard; it is US based. In contrast, ISO is international standard; it is a global standard. The version C89 (ANSI) and C90 (ISO) are essentially the same standard, with only minor editorial differences.

Nowadays, most people refer to the ISO versions (C99, C11, C17, C23), but the foundation was laid by ANSI’s work.

Importance of Standards in Real-World Applications

Standards offer the following advantages in real-world application scenarios −

  • Ensure portability of code across platforms − Standardized C make sure that the same code runs on the different compilers, and hardware without modifications.
  • Help large teams and open-source projects avoid inconsistencies − A common standard prevents teams from writing compiler-specific code, making collaboration and code sharing easier.
  • Provide backward compatibility − New standards retain of the older features, so legacy programs can still compile and run on modern compilers.

Conclusion

The C standards introduced by the ANSI and ISO make the C language portable, reliable, and consistent across platforms. Each version, from C89 to C17, improved its features while keeping backward compatibility. Standardization ensures that C remains widely used in educational institutions, industry, and system programming, making it a powerful and stable language.

Advertisements