11 KiB
[support.c.headers]
17 Language support library [support]
17.15 C headers [support.c.headers]
17.15.1 General [support.c.headers.general]
For compatibility with theC standard library, the C++ standard library provides the C headers shown in Table 47.
The intended use of these headers is for interoperability only.
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.
[Note 1:
The C headers either have no effect, such as <stdbool.h> and <stdalign.h>, or otherwise the corresponding header of the form <cname> provides the same facilities and assuredly defines them in namespace std.
â end note]
[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).
#include <uchar.h> // for char8_t in C, not necessary in C++#include <stddef.h> // for size_t#ifdef __cplusplus // see [cpp.predefined]extern "C" // see [dcl.link]#endifvoid f(char8_t s[], size_t n); â end example]
Table 47 — C headers [tab:c.headers]
| ð <assert.h> |
<inttypes.h> | <signal.h> | <stdckdint.h> | <tgmath.h> |
|---|---|---|---|---|
| ð <complex.h> |
<iso646.h> | <stdalign.h> | <stddef.h> | <time.h> |
| ð <ctype.h> |
<limits.h> | <stdarg.h> | <stdint.h> | <uchar.h> |
| ð <errno.h> |
<locale.h> | <stdatomic.h> | <stdio.h> | <wchar.h> |
| ð <fenv.h> |
<math.h> | <stdbit.h> | <stdlib.h> | <wctype.h> |
| ð <float.h> |
<setjmp.h> | <stdbool.h> | <string.h> |
17.15.2 Header <complex.h> synopsis [complex.h.syn]
#include
The header <complex.h> behaves as if it simply includes the header.
[Note 1:
Names introduced by in namespace std are not placed into the global namespace scope by <complex.h>.
â end note]
17.15.3 Header <iso646.h> synopsis [iso646.h.syn]
The C++ header <iso646.h> is empty.
[Note 1:
and,and_eq,bitand,bitor,compl,not_eq,not,or,or_eq,xor, andxor_eq are keywords in C++ ([lex.key]).
â end note]
17.15.4 Header <stdalign.h> synopsis [stdalign.h.syn]
The contents of the C++ header <stdalign.h> are the same as the C standard library header <stdalign.h>.
See also: ISO/IEC 9899:2024, 7.15
17.15.5 Header <stdbool.h> synopsis [stdbool.h.syn]
The contents of the C++ header <stdbool.h> are the same as the C standard library header <stdbool.h>.
See also: ISO/IEC 9899:2024, 7.19
17.15.6 Header <tgmath.h> synopsis [tgmath.h.syn]
#include #include
The header <tgmath.h> behaves as if it simply includes the headers and.
[Note 1:
The overloads provided in C by type-generic macros are already provided in and by âsufficientâ additional overloads.
â end note]
[Note 2:
Names introduced by or in namespace std are not placed into the global namespace scope by <tgmath.h>.
â end note]
17.15.7 Other C headers [support.c.headers.other]
Every C header
other than<complex.h>,<iso646.h>,<stdalign.h>,
<stdatomic.h>,<stdbit.h>,<stdbool.h>,<stdckdint.h>, and
<tgmath.h>,
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<cname> header is placed within
the global namespace scope,
except for the functions described in [sf.cmath],
the std::lerp function overloads ([c.math.lerp]),
the declaration of std::byte ([cstddef.syn]), and
the functions and function templates described in [support.types.byteops].
It is unspecified whether these names are first declared or defined within namespace scope ([basic.scope.namespace]) of the namespacestd and are then injected into the global namespace scope by explicit using-declarations ([namespace.udecl]).
[Example 1:
The header assuredly provides its declarations and definitions within the namespacestd.
It may also provide these names within the global namespace.
The header <stdlib.h> assuredly provides the same declarations and definitions within the global namespace, much as in ISO/IEC 9899.
It may also provide these names within the namespace std.
â end example]