Home > Blockchain >  Why C language called Standard
Why C language called Standard

Time:06-20

Recently I've read "Extreme C Programming" book and often heard that

C is a Standard

I know, C is standardized by ANSI. But what does it really mean? Is this is about keywords, supported functions or headers?

CodePudding user response:

It means that there is international standardization in the form of a document ISO/IEC 9899:2018 1) stating how compilers and applications should behave. ISO is an international collaboration, consisting of working groups that take input from national standardization institutes such as ANSI/INCITS in USA. So saying that C is standardized by ANSI is wrong unless you happen to live in USA, where the local name for the standard is INCITS/ISO/IEC 9899:2018.

The whole language is specified in this document: terms, behavior, keywords, operators, environment considerations, certain libraries and so on.


1) The official standard costs money to obtain. For student/hobbyist purposes, you can download a draft version of the standard for free though, such as the C11 draft.

CodePudding user response:

If the sentence indeed refers to C being ANSI/ISO standardized, it refers to a lot of things, including your "keywords, supported functions or headers". The C standard defines:

  • The preprocessor directives (defines and includes).
  • The syntax (the grammar, the formal structure): The keywords and other building blocks of the language (literals, operators, identifier syntax) and how these can be combined to expressions and statements in order to form a syntactically correct C program.
  • The semantics of a program (which grammatically correct constructs are allowed, and what is their meaning).
  • The C Standard Library (malloc, printf, memcpy etc.). The "user facing" part of that library are the headers (stdio.h, string.h etc.) which name and describe the functions available in the standard library. The "system facing" part of the standard library is the actual compiled code of those functions, typically in the form of library files in a platform specific format with platform specific names in platform specific locations such as libc.a on a gcc/linux system. Because the standard library is so commonly used by normal programs, no special effort must be made to link to it: The linker does that automatically. (You still need to include the proper header file though to let the compiler know about the function names and the arguments you want to use.)

Saying that C is a "standard" can have both meanings: The ISO standardization detailed above, but also the fact that C, compared to assembler, is an abstraction layer that shields a program from peculiarities of the underlying hardware, for example is word length, its endianness, signedness of its character type etc. The interaction with the "system" a program is running on is abstracted through the aptly named "Standard Library".

A well-written C program runs without or with only minor modification on a wide variety of platforms. In this sense C was a de-facto "standard" for programming for years before its formal ISO standardization at the end of the 1980s, much in the sense that *nix in one of its flavors has become a de-facto standard for server operating systems.

Addendum: After browsing the accessible part of the book that inspired your question I can say with confidence that the author indeed addresses both meanings of "standard": He talks about the different ISO C standard versions, dedicating an entire chapter to C 2018; but he also says the following, on "54% of sample" (I cannot see a page number there; emphasis by me):

The size of a pointer depends on the architecture rather than being a specific C concept. C doesn't worry too much about such hardware-related details, and it tries to provide a generic way of working with pointers and other programming concepts. That is why we know C as a standard.

CodePudding user response:

I know, C is standardized by ANSI

C was standardized by ANSI in 1989 (aka C89).

It was then globally adopted by ISO/IEC JTC1/SC22 Programming Languages in 1990 as ISO/IEC 9899:1990 (aka C90).

Working Group 14 (WG14) of SC22 have subsequently evolved the C Standard as:

  • ISO/IEC 9899:1990 (aka C90)
  • ISO/IEC 9899:1990/AMD1:1995 (aka C95)
  • ISO/IEC 9899:1999 (aka C99)
  • ISO/IEC 9899:2011 (aka C11)
  • ISO/IEC 9899:2018 (aka C18 - although sometimes called C17 as __STDC__ is 200712)
  • ISO/IEC 9899:202x (aka C2x) is pending...

There were a couple of TCs too...

As a Standard it has requirements for conformance.

  • Related