49 lines
3.3 KiB
Markdown
49 lines
3.3 KiB
Markdown
[support.c.headers.general]
|
||
|
||
# 17 Language support library [[support]](./#support)
|
||
|
||
## 17.15 C headers [[support.c.headers]](support.c.headers#general)
|
||
|
||
### 17.15.1 General [support.c.headers.general]
|
||
|
||
[1](#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.1 General [support.c.headers.general]") shown in Table [47](#tab:c.headers "Table 47: C headers")[.](#1.sentence-1)
|
||
|
||
The intended use of these headers is for interoperability only[.](#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[.](#1.sentence-3)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
The C headers either have no effect,
|
||
such as [<stdbool.h>](stdbool.h.syn#header:%3cstdbool.h%3e "17.15.5 Header <stdbool.h> synopsis [stdbool.h.syn]") and [<stdalign.h>](stdalign.h.syn#header:%3cstdalign.h%3e "17.15.4 Header <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[.](#1.sentence-4)
|
||
|
||
â *end note*]
|
||
|
||
[*Example [1](#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)[.](#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.12 Predefined macro names")extern "C" // see [[dcl.link]](dcl.link "9.12 Linkage 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.1 Header <stdckdint.h> synopsis [stdckdint.h.syn]") | [<tgmath.h>](tgmath.h.syn#header:%3ctgmath.h%3e "17.15.6 Header <tgmath.h> synopsis [tgmath.h.syn]") |
|
||
| --- | --- | --- | --- | --- |
|
||
| [ð](#tab:c.headers-row-2)<br>[<complex.h>](complex.h.syn#header:%3ccomplex.h%3e "17.15.2 Header <complex.h> synopsis [complex.h.syn]") | [<iso646.h>](iso646.h.syn#header:%3ciso646.h%3e "17.15.3 Header <iso646.h> synopsis [iso646.h.syn]") | [<stdalign.h>](stdalign.h.syn#header:%3cstdalign.h%3e "17.15.4 Header <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.12 C 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.12 Header <stdbit.h> synopsis [stdbit.h.syn]") | <stdlib.h> | <wctype.h> |
|
||
| [ð](#tab:c.headers-row-6)<br><float.h> | <setjmp.h> | [<stdbool.h>](stdbool.h.syn#header:%3cstdbool.h%3e "17.15.5 Header <stdbool.h> synopsis [stdbool.h.syn]") | <string.h> | |
|