From WikiChip
Difference between revisions of "c/standard library"
< c

m
(Standard Headers)
 
(One intermediate revision by the same user not shown)
Line 9: Line 9:
 
Standard C provides 29 standard headers. The headers may be included in any order. The headers may also be included more than once - the effect of that is as if it was only included once. All standard C functions have external linkage.
 
Standard C provides 29 standard headers. The headers may be included in any order. The headers may also be included more than once - the effect of that is as if it was only included once. All standard C functions have external linkage.
  
 
+
{{collist
{| style="width: 600px; margin-left: auto; margin-right: auto;"
+
| count  = 5
|{{C|assert.h|<assert.h>}}
+
| center = yes
|{{C|complex.h|<complex.h>}}
+
| width = 650px
|{{C|ctype.h|<ctype.h>}}
+
|
|{{C|errno.h|<errno.h>}}
+
* {{c header|assert.h}}
|{{C|fenv.h|<fenv.h>}}
+
* {{c header|complex.h}}
|-
+
* {{c header|ctype.h}}
|{{C|float.h|<float.h>}}
+
* {{c header|errno.h}}
|{{C|inttypes.h|<inttypes.h>}}
+
* {{c header|fenv.h}}
|{{C|iso646.h|<iso646.h>}}
+
* {{c header|float.h}}
|{{C|limits.h|<limits.h>}}
+
* {{c header|inttypes.h}}
|{{C|locale.h|<locale.h>}}
+
* {{c header|iso646.h}}
|-
+
* {{c header|limits.h}}
|{{C|math.h|<math.h>}}
+
* {{c header|locale.h}}
|{{C|setjmp.h|<setjmp.h>}}
+
* {{c header|math.h}}
|{{C|signal.h|<signal.h>}}
+
* {{c header|setjmp.h}}
|{{C|stdalign.h|<stdalign.h>}}
+
* {{c header|signal.h}}
|{{C|stdarg.h|<stdarg.h>}}
+
* {{c header|stdalign.h}}
|-
+
* {{c header|stdarg.h}}
|{{C|stdatomic.h|<stdatomic.h>}}
+
* {{c header|stdatomic.h}}
|{{C|stdbool.h|<stdbool.h>}}
+
* {{c header|stdbool.h}}
|{{C|stddef.h|<stddef.h>}}
+
* {{c header|stddef.h}}
|{{C|stdint.h|<stdint.h>}}
+
* {{c header|stdint.h}}
|{{C|stdio.h|<stdio.h>}}
+
* {{c header|stdio.h}}
|-
+
* {{c header|stdlib.h}}
|{{C|stdlib.h|<stdlib.h>}}
+
* {{c header|stdnoreturn.h}}
|{{C|stdnoreturn.h|<stdnoreturn.h>}}
+
* {{c header|string.h}}
|{{C|string.h|<string.h>}}
+
* {{c header|tgmath.h}}
|{{C|tgmath.h|<tgmath.h>}}
+
* {{c header|threads.h}}
|{{C|threads.h|<threads.h>}}
+
* {{c header|time.h}}
|-
+
* {{c header|uchar.h}}
|{{C|time.h|<time.h>}}
+
* {{c header|wchar.h}}
|{{C|uchar.h|<uchar.h>}}
+
* {{c header|wctype.h}}
|{{C|wchar.h|<wchar.h>}}
+
}}
|{{C|wctype.h|<wctype.h>}}
 
|}
 
  
 
== Optional headers ==
 
== Optional headers ==
Line 70: Line 68:
 
|{{C|ctype.h|<ctype.h>}} || C89 || Provides a set of functions used for classifying characters.
 
|{{C|ctype.h|<ctype.h>}} || C89 || Provides a set of functions used for classifying characters.
 
|-
 
|-
|{{C|errno.h|<errno.h>}} || C89 || Provides a set of predefined values for errno (C)|errno.
+
|{{C|errno.h|<errno.h>}} || C89 || Provides a set of predefined values for {{C|errno}}.
 
|-
 
|-
 
|{{C|fenv.h|<fenv.h>}} || C99 || Provides a set of functions for controlling the floating-point environment.
 
|{{C|fenv.h|<fenv.h>}} || C99 || Provides a set of functions for controlling the floating-point environment.

Latest revision as of 14:28, 9 March 2016

The C standard library is a standardized collection of headers and library functions for the C programming language. The library provides a set of commonly used macros, type definitions, and functions to perform common tasks such as string handling, input/output processing, memory allocation, math computations, thread management, and various other common services.


Standard Headers[edit]

Related functions, necessary types to use those functions and related macros are grouped into headers. Collectively, they are known as the standard headers.

Standard C provides 29 standard headers. The headers may be included in any order. The headers may also be included more than once - the effect of that is as if it was only included once. All standard C functions have external linkage.

Optional headers[edit]

3 of the 29 standard headers are optional:

While implementations are encouraged to support those headers, they are not required to.

Detailed description[edit]

Header Name Since Description
<assert.h> C89 Provides a set of assertion macros used in assisting with debugging and detecting logic errors.
<complex.h> C99 Provides a set of functions used to manipulate complex numbers.
<ctype.h> C89 Provides a set of functions used for classifying characters.
<errno.h> C89 Provides a set of predefined values for errno.
<fenv.h> C99 Provides a set of functions for controlling the floating-point environment.
<float.h> C89 Provides a set of macros defining the implementation of the floating-point environment.
<inttypes.h> C99 Provides a set of exact width integer types.
<iso646.h> NA1 Provides a set of macros that implement an alternative way of expressing various C operators
<limits.h> C89 Provides a set of macros specifying the implementation-specific limits of the integer types.
<locale.h> C89 Provides a set of functions localization functions
<math.h> C89 Provides a set of common mathematical functions.
<setjmp.h> C89 Provides macros to perform non-local jump operators.
<signal.h> C89 Provides a set of signal handling functions.
<stdalign.h> C11 Provides a set of macros for working with object alignments.
<stdarg.h> C89 Provides a set of macros for working with variadic functions
<stdatomic.h> C11 Provides a set of functions for performing atomic operations on data.
<stdbool.h> C99 Provides boolean macros.
<stddef.h> C89 Provides a set of commonly used type definitions within the standard library.
<stdint.h> C99 Provides a set of exact width integer types.
<stdio.h> C89 Provides a set of standard input/output processing functions.
<stdlib.h> C89 Provides core library functions such as memory management and random number generation.
<stdnoreturn.h> C11 Provides a macro for specifying non-returning functions.
<string.h> C89 string handling functions.
<tgmath.h> C99 Provides a set of type-generic math functions.
<threads.h> C11 Provides a set of thread management functions.
<time.h> C89 Provides a set of date and time handling functions.
<uchar.h> C11 Provides a set of Unicode character manipulation functions.
<wchar.h> NA1 string handling functions.
<wctype.h> NA1 Provides a set of functions used for classifying wide characters.

Embedded C[edit]

Main article: Embedded C

Embedded C introduced two optional headers <stdfix.h> and <iohw.h>. The headers not formally part of the standard library.

See also[edit]