C standard library

C standard library

The C standard library (English C standard library) is a standard function library for the C programming language, which contains about 200 frequently used functions for input and output, mathematical operations, string handling, memory management, and other areas. C has, unlike traditional languages ​​(especially Pascal and Fortran ), no built complex functionalities, eg for input and output operations. These must therefore be provided by function libraries are available. In any standard-compliant operating system -based implementation (hosted environment) the C programming language has the standard C library fully be present. In contrast to free-standing environments ( freestanding environment), as they are often found for example in the embedded space, offer only a defined subset of the standard library to be standards compliant.

Construction

Function prototypes, macros, type declarations and other information are stored in so-called headers that integrates the programmer as needed using the C preprocessor into the source code of his program, to tell the compiler how these functions are to be used. Usually, they are in the headers to separate files, but so requires the C standard does not explicitly: the compiler manufacturer only needs to ensure that its C environment behaves as is ob The actual implementation of the functions usually outsourced to a program library. Naming and scope of the headers are now standardized, but the organization of the libraries varies depending on the provider. The C standard library is usually implemented by the compiler manufacturer, however, there are "naked" compiler, such as GCC, which use the existing system in the library. Compiler and system standard library together form the hosted environment here.

Scope

Compared to the libraries of other languages ​​, including Java, for example, the C standard library is minimalist. It provides only a basic set of mathematical functions, functions for string manipulation, type conversion, and file-and console-based input and output. It provides no standardized container data types, as does the C standard library, nor does it provide support for graphical user interfaces, network functionalities and another, which is of course available today in other languages ​​. A great advantage of the small standard library, however, is that providing a standards-compliant C implementation is much easier than other languages, and thus porting C to a new platform is relatively simple.

The largest part of the C standard library has been found developed as a very forward-looking. However, certain areas are now considered errors, but are included because of wider use. The input function gets ( ), for example, is the source of many buffer overflows and was therefore standards C11 also removed from the library of the latest C.

The ISO C standard library currently includes ( ISO C99 ) 24 header. Because some headers were added only in recent revisions to the C standard, they are not supported by compilers that implement an older standard language.

Formation

Since C, unlike other traditional languages ​​such as Pascal or Fortran, has no built-in complex functions eg for input and output operations, formed in the phase prior to the standardization of Circle C programmers that their ideas and implementations for ever again used functions among themselves exchanged. This over time resulted in a considerable function libraries with later served as the basis for the standardization of the C language.

C was developed in the early 1970s by Dennis Ritchie at Bell Laboratories for programming the Unix operating system and won in the following years more and more popularity. Many universities and organizations developed projects for their own variants of the language, so that it soon gave compatibility problems between different implementations. 1983 formed the American National Standards Institute (ANSI), a committee to define a standard C. In December 1989, the work on the language standard ANSI X3.159 - 1989 Programming Language C ( " C89 " ) was completed, which included the C standard library. A year later, the standard by ISO as international standard ISO / IEC 9899:1990 was acquired ( " C90 "). It was followed by further revisions, see also: variants of the C programming language

Header

From the respective versions of the standard, the following headers are defined:

Freestanding implementations

Freestanding implementations only need to provide at least the following headers are available:

Implementations of the C standard library

  • The Glibc is a free (LGPL ) implementation of the standard C library, which is developed in the GNU project with the gcc compiler. Therefore, it is particularly prevalent in the Unix space.
  • Also freely available ( under a BSD license ), the C library implementations of the BSD operating systems FreeBSD, NetBSD and OpenBSD. These represent modern developments of the originally provided by the CSRG C library dar.
  • Programs for Microsoft Windows often use the functionality provided by the "Microsoft Visual C " runtime implementation ( " msvcrt.dll " ) that bears no special name, because it is not available separately.
  • As alternatives are also home to less extensive implementations available, which are especially on embedded systems using, for example, eglibc and the specially developed for μClinux uClibc or diet libc.
  • The klibc is a free (GPL or BSD license ) Minimal implementation of the C standard library from Hans Peter Anvin, which is mainly used during the boot process from the Linux kernel.
  • For the programming of " TI MSP430 " microcontrollers from Texas Instruments can be msp430 - libc used.
  • Bionic (software ) is a free ( BSD license ) implementation of Google for the Android operating system.
de