Chapter 16. The Standard Headers

Each standard library function is declared in one or more of the standard headers. These headers also contain all the macro and type definitions that the C standard provides. This chapter describes the contents and use of the standard headers.

Each of the standard headers contains a set of related function declarations, macros, and type definitions. For example, mathematical functions are declared in the header math.h. The standard headers are also called header files, as the contents of each header are usually stored in a file. Strictly speaking, however, the standard does not require the headers to be organized in files.

The C standard defines the following 29 headers (those marked with an asterisk were added in C11):

assert.h

inttypes.h

signal.h

stdint.h

threads.h*

complex.h

iso646.h

stdalign.h*

stdio.h

time.h

ctype.h

limits.h

stdarg.h

stdlib.h

uchar.h*

errno.h

locale.h

stdatomic.h*

stdnoreturn.h*

wchar.h

fenv.h

math.h

stdbool.h

string.h

wctype.h

float.h

setjmp.h

stddef.h

tgmath.h

The headers complex.h, stdatomic.h, and threads.h are optional components. There are standard macros that a C11 implementation can define to indicate that it does not include these options. If the macro __STDC_NO_COMPLEX__, __STDC_NO_ATOMICS__, or __STDC_NO_THREADS__ is defined as equal to 1, the implementation does not include the corresponding optional header.

Using the Standard Headers

You can add the contents of a standard header to a source ...

Get C in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.