This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,184 @@
[support.c.headers]
# 17 Language support library [[support]](./#support)
## 17.15 C headers [support.c.headers]
### [17.15.1](#general) General [[support.c.headers.general]](support.c.headers.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6575)
For compatibility with theC standard library, the C++ standard library provides
the [*C headers*](#def:headers,C_library "17.15.1General[support.c.headers.general]") shown in Table [47](#tab:c.headers "Table 47: C headers")[.](#general-1.sentence-1)
The intended use of these headers is for interoperability only[.](#general-1.sentence-2)
It is possible that C++ source files need to include
one of these headers in order to be valid C.
Source files that are not intended to also be valid C
should not use any of the C headers[.](#general-1.sentence-3)
[*Note [1](#general-note-1)*:
The C headers either have no effect,
such as [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") and [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]"), or
otherwise the corresponding header of the form <c*name*> provides the same facilities and
assuredly defines them in namespace std[.](#general-1.sentence-4)
— *end note*]
[*Example [1](#general-example-1)*:
The following source file is both valid C++ and valid C.
Viewed as C++, it declares a function with C language linkage;
viewed as C it simply declares a function (and provides a prototype)[.](#general-1.sentence-5)
#include <uchar.h> // for char8_t in C, not necessary in C++#include <stddef.h> // for size_t#ifdef __cplusplus // see [[cpp.predefined]](cpp.predefined "15.12Predefined macro names")extern "C" // see [[dcl.link]](dcl.link "9.12Linkage specifications")#endifvoid f(char8_t s[], size_t n); — *end example*]
Table [47](#tab:c.headers) — C headers [[tab:c.headers]](./tab:c.headers)
| [🔗](#tab:c.headers-row-1)<br><assert.h> | <inttypes.h> | <signal.h> | [<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]") | [<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]") |
| --- | --- | --- | --- | --- |
| [🔗](#tab:c.headers-row-2)<br>[<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]") | [<iso646.h>](#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]") | [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]") | <stddef.h> | <time.h> |
| [🔗](#tab:c.headers-row-3)<br><ctype.h> | <limits.h> | <stdarg.h> | <stdint.h> | <uchar.h> |
| [🔗](#tab:c.headers-row-4)<br><errno.h> | <locale.h> | [<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]") | <stdio.h> | <wchar.h> |
| [🔗](#tab:c.headers-row-5)<br><fenv.h> | <math.h> | [<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]") | <stdlib.h> | <wctype.h> |
| [🔗](#tab:c.headers-row-6)<br><float.h> | <setjmp.h> | [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") | <string.h> | |
### [17.15.2](#complex.h.syn) Header <complex.h> synopsis [[complex.h.syn]](complex.h.syn)
[🔗](#header:%3ccomplex.h%3e)
#include <complex>
[1](#complex.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6652)
The header [<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]") behaves as if it simply includes the header[<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]")[.](#complex.h.syn-1.sentence-1)
[2](#complex.h.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6657)
[*Note [1](#complex.h.syn-note-1)*:
Names introduced by [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]") in namespace std are not placed into the global namespace scope by [<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]")[.](#complex.h.syn-2.sentence-1)
— *end note*]
### [17.15.3](#iso646.h.syn) Header <iso646.h> synopsis [[iso646.h.syn]](iso646.h.syn)
[1](#iso646.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6666)
The C++ header [<iso646.h>](#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]") is empty[.](#iso646.h.syn-1.sentence-1)
[*Note [1](#iso646.h.syn-note-1)*:
and,and_eq,bitand,bitor,compl,not_eq,not,or,or_eq,xor, andxor_eq are keywords in C++ ([[lex.key]](lex.key "5.12Keywords"))[.](#iso646.h.syn-1.sentence-2)
— *end note*]
### [17.15.4](#stdalign.h.syn) Header <stdalign.h> synopsis [[stdalign.h.syn]](stdalign.h.syn)
[1](#stdalign.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6686)
The contents of the C++ header [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]") are the same as the C
standard library header [<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]")[.](#stdalign.h.syn-1.sentence-1)
See also: ISO/IEC 9899:2024, 7.15
### [17.15.5](#stdbool.h.syn) Header <stdbool.h> synopsis [[stdbool.h.syn]](stdbool.h.syn)
[1](#stdbool.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6695)
The contents of the C++ header [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]") are the same as the C
standard library header [<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]")[.](#stdbool.h.syn-1.sentence-1)
See also: ISO/IEC 9899:2024, 7.19
### [17.15.6](#tgmath.h.syn) Header <tgmath.h> synopsis [[tgmath.h.syn]](tgmath.h.syn)
[🔗](#header:%3ctgmath.h%3e)
#include <cmath>#include <complex>
[1](#tgmath.h.syn-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6709)
The header [<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]") behaves as if it simply includes the headers[<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") and[<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]")[.](#tgmath.h.syn-1.sentence-1)
[2](#tgmath.h.syn-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6715)
[*Note [1](#tgmath.h.syn-note-1)*:
The overloads provided in C by type-generic macros
are already provided in [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]") and [<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") by “sufficient” additional overloads[.](#tgmath.h.syn-2.sentence-1)
— *end note*]
[3](#tgmath.h.syn-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6722)
[*Note [2](#tgmath.h.syn-note-2)*:
Names introduced by [<cmath>](cmath.syn#header:%3ccmath%3e "29.7.1Header <cmath> synopsis[cmath.syn]") or [<complex>](complex.syn#header:%3ccomplex%3e "29.4.2Header <complex> synopsis[complex.syn]") in namespace std are not placed into the global namespace scope by [<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]")[.](#tgmath.h.syn-3.sentence-1)
— *end note*]
### [17.15.7](#other) Other C headers [[support.c.headers.other]](support.c.headers.other)
[1](#other-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6731)
Every C header
other than[<complex.h>](#header:%3ccomplex.h%3e "17.15.2Header <complex.h> synopsis[complex.h.syn]"),[<iso646.h>](#header:%3ciso646.h%3e "17.15.3Header <iso646.h> synopsis[iso646.h.syn]"),[<stdalign.h>](#header:%3cstdalign.h%3e "17.15.4Header <stdalign.h> synopsis[stdalign.h.syn]"),
[<stdatomic.h>](stdatomic.h.syn#header:%3cstdatomic.h%3e "32.5.12C compatibility[stdatomic.h.syn]"),[<stdbit.h>](stdbit.h.syn#header:%3cstdbit.h%3e "22.12Header <stdbit.h> synopsis[stdbit.h.syn]"),[<stdbool.h>](#header:%3cstdbool.h%3e "17.15.5Header <stdbool.h> synopsis[stdbool.h.syn]"),[<stdckdint.h>](stdckdint.h.syn#header:%3cstdckdint.h%3e "29.11.1Header <stdckdint.h> synopsis[stdckdint.h.syn]"), and
[<tgmath.h>](#header:%3ctgmath.h%3e "17.15.6Header <tgmath.h> synopsis[tgmath.h.syn]"),
each of
which has a name of the form<*name*.h>,
behaves as if each name placed in the standard library namespace by
the corresponding<c*name*> header is placed within
the global namespace scope,
except for the functions described in [[sf.cmath]](sf.cmath "29.7.6Mathematical special functions"),
the std::lerp function overloads ([[c.math.lerp]](c.math.lerp "29.7.4Linear interpolation")),
the declaration of std::byte ([[cstddef.syn]](cstddef.syn "17.2.1Header <cstddef> synopsis")), and
the functions and function templates described in [[support.types.byteops]](support.types.byteops "17.2.5byte type operations")[.](#other-1.sentence-1)
It is unspecified whether these names are first declared or defined within
namespace scope ([[basic.scope.namespace]](basic.scope.namespace "6.4.6Namespace scope")) of the namespacestd and are then injected into the global namespace scope by
explicit [*using-declaration*](namespace.udecl#nt:using-declaration "9.10The using declaration[namespace.udecl]")*s* ([[namespace.udecl]](namespace.udecl "9.10The using declaration"))[.](#other-1.sentence-2)
[2](#other-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/support.tex#L6760)
[*Example [1](#other-example-1)*:
The header [<cstdlib>](cstdlib.syn#header:%3ccstdlib%3e "17.2.2Header <cstdlib> synopsis[cstdlib.syn]") assuredly
provides its declarations and definitions within the namespacestd[.](#other-2.sentence-1)
It may also provide these names within the
global namespace[.](#other-2.sentence-2)
The header [<stdlib.h>](#header:%3cstdlib.h%3e "17.15.1General[support.c.headers.general]") assuredly provides the same declarations and definitions within
the global namespace,
much as in ISO/IEC 9899[.](#other-2.sentence-3)
It may also provide these names within
the namespace std[.](#other-2.sentence-4)
— *end example*]