From 24ccaf84410e1924d797a6eabf9978d4bc0f1af5 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Wed, 13 Oct 2021 13:53:51 +0200 Subject: [PATCH 1/2] P2340R1 Clarifying the status of the "C headers" --- source/compatibility.tex | 12 +-- source/future.tex | 185 ---------------------------------- source/lib-intro.tex | 8 +- source/support.tex | 212 +++++++++++++++++++++++++++++++++++++++ source/xrefdelta.tex | 10 ++ 5 files changed, 232 insertions(+), 195 deletions(-) diff --git a/source/compatibility.tex b/source/compatibility.tex index 7ca0081222..b9370556c8 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -2166,7 +2166,7 @@ \effect A valid ISO C expression utilizing the decrement operator on a \tcode{bool} lvalue -(for instance, via the C typedef in \libdeprheaderref{stdbool.h}) +(for instance, via the C typedef in \libheaderref{stdbool.h}) is ill-formed in \Cpp{}. \diffref{expr.sizeof,expr.cast} @@ -2794,7 +2794,7 @@ \pnum For compatibility with the C standard library\indextext{library!C standard}, the \Cpp{} standard library provides the C headers enumerated -in~\ref{depr.c.headers}, but their use is deprecated in \Cpp{}. +in~\ref{support.c.headers}, but their use is deprecated in \Cpp{}. \pnum There are no \Cpp{} headers for the C standard library's headers @@ -2857,7 +2857,7 @@ \tcode{xor_eq} are keywords in \Cpp{}\iref{lex.key}, and are not introduced as macros -by \libdeprheaderref{iso646.h}. +by \libheaderref{iso646.h}. \rSec3[diff.header.stdalign.h]{Header \tcode{}} \indexhdr{stdalign.h}% @@ -2865,7 +2865,7 @@ \pnum The token \tcode{alignas} is a keyword in \Cpp{}\iref{lex.key}, and is not introduced as a macro -by \libdeprheaderref{stdalign.h}. +by \libheaderref{stdalign.h}. \rSec3[diff.header.stdbool.h]{Header \tcode{}} \indexhdr{stdbool.h}% @@ -2874,7 +2874,7 @@ The tokens \tcode{bool}, \tcode{true}, and \tcode{false} are keywords in \Cpp{}\iref{lex.key}, and are not introduced as macros -by \libdeprheaderref{stdbool.h}. +by \libheaderref{stdbool.h}. \rSec3[diff.null]{Macro \tcode{NULL}} @@ -2927,7 +2927,7 @@ declares the names \tcode{nullptr_t}, \tcode{byte}, and \tcode{to_integer}, and the operators and operator templates in \iref{support.types.byteops}, in addition to the names declared in -\libheaderrefx{stddef.h}{depr.c.headers} in the C standard library. +\libheaderrefx{stddef.h}{support.c.headers} in the C standard library. \rSec2[diff.mods.to.behavior]{Modifications to behavior} diff --git a/source/future.tex b/source/future.tex index 52de1a6d20..7b63d953d9 100644 --- a/source/future.tex +++ b/source/future.tex @@ -196,191 +196,6 @@ before the qualified name of a class or alias template without a template argument list is deprecated. -\rSec1[depr.c.headers]{C headers} - -\rSec2[depr.c.headers.general]{General} - -\pnum -For compatibility with the -\indextext{library!C standard}% -C standard library, the \Cpp{} standard library provides -the \defnx{C headers}{headers!C library} shown in \tref{depr.c.headers}. - -\begin{multicolfloattable}{C headers}{depr.c.headers} -{lllll} -\libheaderdef{assert.h} \\ -\libheader{complex.h} \\ -\libheaderdef{ctype.h} \\ -\libheaderdef{errno.h} \\ -\libheaderdef{fenv.h} \\ -\libheaderdef{float.h} \\ -\columnbreak -\libheaderdef{inttypes.h} \\ -\libheader{iso646.h} \\ -\libheaderdef{limits.h} \\ -\libheaderdef{locale.h} \\ -\libheaderdef{math.h} \\ -\libheaderdef{setjmp.h} \\ -\columnbreak -\libheaderdef{signal.h} \\ -\libheader{stdalign.h} \\ -\libheaderdef{stdarg.h} \\ -\libheader{stdatomic.h} \\ -\libheader{stdbool.h} \\ -\libheaderdef{stddef.h} \\ -\columnbreak -\libheaderdef{stdint.h} \\ -\libheaderdef{stdio.h} \\ -\libheaderdef{stdlib.h} \\ -\libheaderdef{string.h} \\ -\libheader{tgmath.h} \\ -\libheaderdef{time.h} \\ -\columnbreak -\libheaderdef{uchar.h} \\ -\libheaderdef{wchar.h} \\ -\libheaderdef{wctype.h} \\ -\end{multicolfloattable} - -\rSec2[depr.complex.h.syn]{Header \tcode{} synopsis} - -\indexheader{complex.h}% -\begin{codeblock} -#include -\end{codeblock} - -\pnum -The header \libheader{complex.h} -behaves as if it simply includes the header -\libheaderref{complex}. - -\pnum -\begin{note} -Names introduced by \libheader{complex} in namespace \tcode{std} -are not placed into the global namespace scope by \libheader{complex.h}. -\end{note} - -\rSec2[depr.iso646.h.syn]{Header \tcode{} synopsis} - -\indexheader{iso646.h}% -\pnum -The \Cpp{} header \libheader{iso646.h} is empty. -\begin{note} -\tcode{and}, -\tcode{and_eq}, -\tcode{bitand}, -\tcode{bitor}, -\tcode{compl}, -\tcode{not_eq}, -\tcode{not}, -\tcode{or}, -\tcode{or_eq}, -\tcode{xor}, and -\tcode{xor_eq} -are keywords in \Cpp{}\iref{lex.key}. -\end{note} - -\rSec2[depr.stdalign.h.syn]{Header \tcode{} synopsis} - -\indexheader{stdalign.h}% -\indexlibraryglobal{__alignas_is_defined}% -\begin{codeblock} -#define @\xname{alignas_is_defined}@ 1 -\end{codeblock} - -\pnum -The contents of the \Cpp{} header \libheader{stdalign.h} are the same as the C -standard library header \libheader{stdalign.h}, with the following changes: -The header \libheader{stdalign.h} does not -define a macro named \tcode{alignas}. - -\xrefc{7.15} - -\rSec2[depr.stdbool.h.syn]{Header \tcode{} synopsis} - -\indexheader{stdbool.h}% -\indexhdr{stdbool.h}% -\indexlibraryglobal{__bool_true_false_are_defined}% -\begin{codeblock} -#define @\xname{bool_true_false_are_defined}@ 1 -\end{codeblock} - -\pnum -The contents of the \Cpp{} header \libheader{stdbool.h} are the same as the C -standard library header \libheader{stdbool.h}, with the following changes: -The header \libheader{stdbool.h} does not -define macros named \tcode{bool}, \tcode{true}, or \tcode{false}. - -\xrefc{7.18} - -\rSec2[depr.tgmath.h.syn]{Header \tcode{} synopsis} - -\indexheader{tgmath.h}% -\begin{codeblock} -#include -#include -\end{codeblock} - -\pnum -The header \libheader{tgmath.h} -behaves as if it simply includes the headers -\libheaderref{cmath} and -\libheaderref{complex}. - -\pnum -\begin{note} -The overloads provided in C by type-generic macros -are already provided in \libheader{complex} and \libheader{cmath} -by ``sufficient'' additional overloads. -\end{note} - -\pnum -\begin{note} -Names introduced by \libheader{cmath} or \libheader{complex} -in namespace \tcode{std} -are not placed into the global namespace scope by \libheader{tgmath.h}. -\end{note} - -\rSec2[depr.c.headers.other]{Other C headers} - -\pnum -Every C header -other than -\libdeprheaderref{complex.h}, -\libdeprheaderref{iso646.h}, -\libdeprheaderref{stdalign.h},\newline -\libheaderref{stdatomic.h}, -\libdeprheaderref{stdbool.h}, and -\libdeprheaderref{tgmath.h}, -each of -which has a name of the form -\indextext{header!C}% -\tcode{<\placeholder{name}.h>}, -behaves as if each name placed in the standard library namespace by -the corresponding -\tcode{} -header is placed within -the global namespace scope, -except for the functions described in \ref{sf.cmath}, -the declaration of \tcode{std::byte}\iref{cstddef.syn}, and -the functions and function templates described in \ref{support.types.byteops}. -It is unspecified whether these names are first declared or defined within -namespace scope\iref{basic.scope.namespace} of the namespace -\tcode{std} and are then injected into the global namespace scope by -explicit \grammarterm{using-declaration}{s}\iref{namespace.udecl}. - -\pnum -\begin{example} -The header \libheader{cstdlib} assuredly -provides its declarations and definitions within the namespace -\tcode{std}. It may also provide these names within the -global namespace. -The header \libheader{stdlib.h} -assuredly provides the same declarations and definitions within -the global namespace, -much as in the C Standard. It may also provide these names within -the namespace \tcode{std}. -\end{example} - \rSec1[depr.res.on.required]{Requires paragraph} \pnum diff --git a/source/lib-intro.tex b/source/lib-intro.tex index 3f85b183ff..ea92b42015 100644 --- a/source/lib-intro.tex +++ b/source/lib-intro.tex @@ -913,7 +913,7 @@ or namespaces nested within namespace \tcode{std}. \begin{footnote} -The C standard library headers\iref{depr.c.headers} also define +The C standard library headers\iref{support.c.headers} also define names within the global namespace, while the \Cpp{} headers for C library facilities\iref{headers} can also define names within the global namespace. \end{footnote} @@ -1150,7 +1150,7 @@ \end{footnote} \pnum -\ref{depr.c.headers}, C standard library headers, describes the effects of using +\ref{support.c.headers}, C standard library headers, describes the effects of using the \tcode{\placeholder{name}.h} (C header) form in a \Cpp{} program. \begin{footnote} The @@ -1358,7 +1358,7 @@ \indextext{unit!translation}% Each may be included more than once, with no effect different from being included exactly once, except that the effect of including either -\libheaderref{cassert} or \libheaderrefx{assert.h}{depr.c.headers} +\libheaderref{cassert} or \libheaderrefx{assert.h}{support.c.headers} depends each time on the lexically current definition of \indextext{\idxcode{NDEBUG}}% \indexlibraryglobal{NDEBUG}% @@ -2898,7 +2898,7 @@ included after any other header that also defines it\iref{basic.def.odr}. \pnum -The C standard library headers\iref{depr.c.headers} +The C standard library headers\iref{support.c.headers} shall include only their corresponding \Cpp{} standard library header, as described in~\ref{headers}. diff --git a/source/support.tex b/source/support.tex index f03917530e..a2a87ddf36 100644 --- a/source/support.tex +++ b/source/support.tex @@ -5877,3 +5877,215 @@ corresponding to the signal that caused the invocation of the handler. \xrefc{7.14} + +\rSec1[support.c.headers]{C headers} + +\rSec2[support.c.headers.general]{General} + +\pnum +For compatibility with the +\indextext{library!C standard}% +C standard library, the \Cpp{} standard library provides +the \defnx{C headers}{headers!C library} shown in \tref{c.headers}. +The intended use of these headers is for interoperability only. +It is possible that \Cpp{} source files need to include +one of these headers in order to be valid ISO C. +Source files that are not intended to also be valid ISO C +should not use any of the C headers. + +\begin{note} +The C headers either have no effect, +such as \libheaderref{stdbool.h} and \libheaderref{stdalign.h}, or +otherwise the corresponding header of the form \libheader{c\placeholder{name}} +provides the same facilities and +assuredly defines them in namespace \tcode{std}. +\end{note} +\begin{example} +The following source file is both valid \Cpp{} and valid ISO C. +Viewed as \Cpp{}, it declares a function with C language linkage; +viewed as C it simply declares a function (and provides a prototype). +\begin{codeblock} +#include // for \tcode{bool} in C, no effect in \Cpp{} +#include // for \tcode{size_t} + +#ifdef __cplusplus // see \ref{cpp.predefined} +extern "C" // see \ref{dcl.link} +#endif +void f(bool b[], size_t n); +\end{codeblock} +\end{example} + +\begin{multicolfloattable}{C headers}{c.headers} +{lllll} +\libheaderdef{assert.h} \\ +\libheader{complex.h} \\ +\libheaderdef{ctype.h} \\ +\libheaderdef{errno.h} \\ +\libheaderdef{fenv.h} \\ +\libheaderdef{float.h} \\ +\columnbreak +\libheaderdef{inttypes.h} \\ +\libheader{iso646.h} \\ +\libheaderdef{limits.h} \\ +\libheaderdef{locale.h} \\ +\libheaderdef{math.h} \\ +\libheaderdef{setjmp.h} \\ +\columnbreak +\libheaderdef{signal.h} \\ +\libheader{stdalign.h} \\ +\libheaderdef{stdarg.h} \\ +\libheader{stdatomic.h} \\ +\libheader{stdbool.h} \\ +\libheaderdef{stddef.h} \\ +\columnbreak +\libheaderdef{stdint.h} \\ +\libheaderdef{stdio.h} \\ +\libheaderdef{stdlib.h} \\ +\libheaderdef{string.h} \\ +\libheader{tgmath.h} \\ +\libheaderdef{time.h} \\ +\columnbreak +\libheaderdef{uchar.h} \\ +\libheaderdef{wchar.h} \\ +\libheaderdef{wctype.h} \\ +\end{multicolfloattable} + +\rSec2[complex.h.syn]{Header \tcode{} synopsis} + +\indexheader{complex.h}% +\begin{codeblock} +#include +\end{codeblock} + +\pnum +The header \libheader{complex.h} +behaves as if it simply includes the header +\libheaderref{complex}. + +\pnum +\begin{note} +Names introduced by \libheader{complex} in namespace \tcode{std} +are not placed into the global namespace scope by \libheader{complex.h}. +\end{note} + +\rSec2[iso646.h.syn]{Header \tcode{} synopsis} + +\indexheader{iso646.h}% +\pnum +The \Cpp{} header \libheader{iso646.h} is empty. +\begin{note} +\tcode{and}, +\tcode{and_eq}, +\tcode{bitand}, +\tcode{bitor}, +\tcode{compl}, +\tcode{not_eq}, +\tcode{not}, +\tcode{or}, +\tcode{or_eq}, +\tcode{xor}, and +\tcode{xor_eq} +are keywords in \Cpp{}\iref{lex.key}. +\end{note} + +\rSec2[stdalign.h.syn]{Header \tcode{} synopsis} + +\indexheader{stdalign.h}% +\indexlibraryglobal{__alignas_is_defined}% +\begin{codeblock} +#define @\xname{alignas_is_defined}@ 1 +\end{codeblock} + +\pnum +The contents of the \Cpp{} header \libheader{stdalign.h} are the same as the C +standard library header \libheader{stdalign.h}, with the following changes: +The header \libheader{stdalign.h} does not +define a macro named \tcode{alignas}. + +\xrefc{7.15} + +\rSec2[stdbool.h.syn]{Header \tcode{} synopsis} + +\indexheader{stdbool.h}% +\indexhdr{stdbool.h}% +\indexlibraryglobal{__bool_true_false_are_defined}% +\begin{codeblock} +#define @\xname{bool_true_false_are_defined}@ 1 +\end{codeblock} + +\pnum +The contents of the \Cpp{} header \libheader{stdbool.h} are the same as the C +standard library header \libheader{stdbool.h}, with the following changes: +The header \libheader{stdbool.h} does not +define macros named \tcode{bool}, \tcode{true}, or \tcode{false}. + +\xrefc{7.18} + +\rSec2[tgmath.h.syn]{Header \tcode{} synopsis} + +\indexheader{tgmath.h}% +\begin{codeblock} +#include +#include +\end{codeblock} + +\pnum +The header \libheader{tgmath.h} +behaves as if it simply includes the headers +\libheaderref{cmath} and +\libheaderref{complex}. + +\pnum +\begin{note} +The overloads provided in C by type-generic macros +are already provided in \libheader{complex} and \libheader{cmath} +by ``sufficient'' additional overloads. +\end{note} + +\pnum +\begin{note} +Names introduced by \libheader{cmath} or \libheader{complex} +in namespace \tcode{std} +are not placed into the global namespace scope by \libheader{tgmath.h}. +\end{note} + +\rSec2[support.c.headers.other]{Other C headers} + +\pnum +Every C header +other than +\libheaderref{complex.h}, +\libheaderref{iso646.h}, +\libheaderref{stdalign.h},\newline +\libheaderref{stdatomic.h}, +\libheaderref{stdbool.h}, and +\libheaderref{tgmath.h}, +each of +which has a name of the form +\indextext{header!C}% +\tcode{<\placeholder{name}.h>}, +behaves as if each name placed in the standard library namespace by +the corresponding +\tcode{} +header is placed within +the global namespace scope, +except for the functions described in \ref{sf.cmath}, +the declaration of \tcode{std::byte}\iref{cstddef.syn}, and +the functions and function templates described in \ref{support.types.byteops}. +It is unspecified whether these names are first declared or defined within +namespace scope\iref{basic.scope.namespace} of the namespace +\tcode{std} and are then injected into the global namespace scope by +explicit \grammarterm{using-declaration}{s}\iref{namespace.udecl}. + +\pnum +\begin{example} +The header \libheader{cstdlib} assuredly +provides its declarations and definitions within the namespace +\tcode{std}. It may also provide these names within the +global namespace. +The header \libheader{stdlib.h} +assuredly provides the same declarations and definitions within +the global namespace, +much as in the C Standard. It may also provide these names within +the namespace \tcode{std}. +\end{example} diff --git a/source/xrefdelta.tex b/source/xrefdelta.tex index 42363268d8..aa5fc326ea 100644 --- a/source/xrefdelta.tex +++ b/source/xrefdelta.tex @@ -72,5 +72,15 @@ % P2128R6 Multidimensional subscript operator \removedxref{depr.comma.subscript} +% P2340R1 Clarifying the status of the "C headers" +\movedxref{depr.c.headers}{support.c.headers} +\movedxref{depr.c.headers.general}{support.c.headers.general} +\movedxref{depr.c.headers.other}{support.c.headers.other} +\movedxref{depr.complex.h.syn}{complex.h.syn} +\movedxref{depr.iso646.h.syn}{iso646.h.syn} +\movedxref{depr.stdalign.h.syn}{stdalign.h.syn} +\movedxref{depr.stdbool.h.syn}{stdbool.h.syn} +\movedxref{depr.tgmath.h.syn}{tgmath.h.syn} + % Deprecated features. %\deprxref{old.label} (if moved to depr.old.label, otherwise use \movedxref) From 347ea5448f16e32736ed3e384328d961870ef36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Wed, 20 Oct 2021 14:51:08 +0100 Subject: [PATCH 2/2] [diff.mods.to.headers] Delete statement that C headers are deprecated. This deletion should have been part of P2340R1. --- source/compatibility.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/compatibility.tex b/source/compatibility.tex index b9370556c8..f93f1b0903 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -2794,7 +2794,7 @@ \pnum For compatibility with the C standard library\indextext{library!C standard}, the \Cpp{} standard library provides the C headers enumerated -in~\ref{support.c.headers}, but their use is deprecated in \Cpp{}. +in~\ref{support.c.headers}. \pnum There are no \Cpp{} headers for the C standard library's headers