Lably
Skip to content

C standard library

Standard library for the C programming language

  • 14 min read
  • 7 chapters

Related on Lably

Through Data type, Function (computer programming) and String (computer science)

The C standard library provides and includes macros, type definitions and functions for tasks such as string manipulation, mathematical computation, input/output processing, memory management, and input/output.

Application programming interface (API)

Header files

The application programming interface (API) of the C standard library is declared in a number of header files. Each header file contains one or more function declarations, data type definitions, and macros.

An implementation of a version of the standard for the C language can be described as hosted or freestanding. A hosted implementation supports the entire standard, and requires that all of the header files specified in the standard be present; these are typically implementations for programs running on an operating system. A freestanding implementation is not required to implement language features in the C library other than those specified in that version of the operating system as being required in freestanding implementations; these are typically implementations for programs running on a very limited operating system or directly on the hardware.

After a long period of stability, three new header files (<iso646.h>, <wchar.h>, and <wctype.h>) were added with Normative Addendum 1 (NA1), an addition to the C Standard ratified in 1995. Six more header files (<complex.h>, <fenv.h>, <inttypes.h>, <stdbool.h>, <stdint.h>, and <tgmath.h>) were added with C99, a revision to the C Standard published in 1999, five more files (<stdalign.h>, <stdatomic.h>, <stdnoreturn.h>, <threads.h>, and <uchar.h>) with C11 in 2011, two more files (<stdbit.h> and <stdckdint.h>) with C23 in 2023, and two more files (<stdcountof.h> and <stdmchar.h>) in the upcoming C29, projected for 2029. In total, there are now 33 header files:

Legend:
: Deprecated
: Removed

Three of the header files (<complex.h>, <stdatomic.h>, and <threads.h>) are conditional features that implementations are not required to support.

The POSIX standard added several nonstandard C headers for Unix-specific functionality. Many have found their way to other architectures. Examples include <fcntl.h> and <unistd.h>. A number of other groups are using other nonstandard headers – the GNU C Library has <alloca.h>, and OpenVMS has the va_count() function.

Documentation

On Unix-like systems, the authoritative documentation of the API is provided in the form of man pages. On most systems, man pages on standard library functions are in section 3; section 7 may contain some more generic pages on underlying concepts (e.g. man 7 math_error in Linux).

Sign in to keep reading

6 more chapters are free with a Lably account.

More in Computing and communication