[diff.library] # Annex C (informative) Compatibility [[diff]](./#diff) ## C.8 C standard library [diff.library] ### [C.8.1](#general) General [[diff.library.general]](diff.library.general) [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3683) Subclause [diff.library] summarizes the explicit changes in headers, definitions, declarations, or behavior between the C standard library in the C standard and the parts of the C++ standard library that were included from the C standard library[.](#general-1.sentence-1) ### [C.8.2](#diff.mods.to.headers) Modifications to headers [[diff.mods.to.headers]](diff.mods.to.headers) [1](#diff.mods.to.headers-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3691) For compatibility with the C standard library, the C++ standard library provides the C headers enumerated in [[support.c.headers]](support.c.headers "17.15 C headers")[.](#diff.mods.to.headers-1.sentence-1) [2](#diff.mods.to.headers-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3696) There are no C++ headers for the C standard library's headers and , nor are these headers from the C standard library headers themselves part of C++[.](#diff.mods.to.headers-2.sentence-1) [3](#diff.mods.to.headers-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3701) The C headers [](complex.h.syn#header:%3ccomplex.h%3e "17.15.2 Header synopsis [complex.h.syn]") and[](tgmath.h.syn#header:%3ctgmath.h%3e "17.15.6 Header synopsis [tgmath.h.syn]") do not contain any of the content from the C standard library and instead merely include other headers from the C++ standard library[.](#diff.mods.to.headers-3.sentence-1) ### [C.8.3](#diff.mods.to.definitions) Modifications to definitions [[diff.mods.to.definitions]](diff.mods.to.definitions) #### [C.8.3.1](#diff.char16) Types char8_t, char16_t, and char32_t [[diff.char16]](diff.char16) [1](#diff.char16-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3711) The types char8_t, char16_t, and char32_t are distinct types rather than typedefs to existing integral types[.](#diff.char16-1.sentence-1) The tokens char8_t, char16_t, and char32_t are keywords in C++ ([[lex.key]](lex.key "5.12 Keywords"))[.](#diff.char16-1.sentence-2) They do not appear as macro or type names defined in[](cuchar.syn#header:%3ccuchar%3e "28.7.4 Header synopsis [cuchar.syn]")[.](#diff.char16-1.sentence-3) #### [C.8.3.2](#diff.wchar.t) Type wchar_t [[diff.wchar.t]](diff.wchar.t) [1](#diff.wchar.t-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3721) The type wchar_t is a distinct type rather than a typedef to an existing integral type[.](#diff.wchar.t-1.sentence-1) The token wchar_t is a keyword in C++ ([[lex.key]](lex.key "5.12 Keywords"))[.](#diff.wchar.t-1.sentence-2) It does not appear as a macro or type name defined in any of[](cstddef.syn#header:%3ccstddef%3e "17.2.1 Header synopsis [cstddef.syn]"),[](cstdlib.syn#header:%3ccstdlib%3e "17.2.2 Header synopsis [cstdlib.syn]"), or [](cwchar.syn#header:%3ccwchar%3e "28.7.3 Header synopsis [cwchar.syn]")[.](#diff.wchar.t-1.sentence-3) #### [C.8.3.3](#diff.header.iso646.h) Header [[diff.header.iso646.h]](diff.header.iso646.h) [1](#diff.header.iso646.h-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3733) The tokensand,and_eq,bitand,bitor,compl,not,not_eq,or,or_eq,xor, andxor_eq are keywords in C++ ([[lex.key]](lex.key "5.12 Keywords")), and are not introduced as macros by [](iso646.h.syn#header:%3ciso646.h%3e "17.15.3 Header synopsis [iso646.h.syn]")[.](#diff.header.iso646.h-1.sentence-1) #### [C.8.3.4](#diff.null) Macro NULL [[diff.null]](diff.null) [1](#diff.null-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3753) The macroNULL, defined in any of[](clocale.syn#header:%3cclocale%3e "28.3.5.1 Header synopsis [clocale.syn]"),[](cstddef.syn#header:%3ccstddef%3e "17.2.1 Header synopsis [cstddef.syn]"),[](cstdio.syn#header:%3ccstdio%3e "31.13.1 Header synopsis [cstdio.syn]"),[](cstdlib.syn#header:%3ccstdlib%3e "17.2.2 Header synopsis [cstdlib.syn]"),[](cstring.syn#header:%3ccstring%3e "27.5.1 Header synopsis [cstring.syn]"),[](ctime.syn#header:%3cctime%3e "30.15 Header synopsis [ctime.syn]"), or [](cwchar.syn#header:%3ccwchar%3e "28.7.3 Header synopsis [cwchar.syn]"), is an implementation-defined null pointer constant in C++ ([[support.types]](support.types "17.2 Common definitions"))[.](#diff.null-1.sentence-1) ### [C.8.4](#diff.mods.to.declarations) Modifications to declarations [[diff.mods.to.declarations]](diff.mods.to.declarations) [1](#diff.mods.to.declarations-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3769) Header [](cstring.syn#header:%3ccstring%3e "27.5.1 Header synopsis [cstring.syn]"): The following functions have different declarations: - [(1.1)](#diff.mods.to.declarations-1.1) strchr - [(1.2)](#diff.mods.to.declarations-1.2) strpbrk - [(1.3)](#diff.mods.to.declarations-1.3) strrchr - [(1.4)](#diff.mods.to.declarations-1.4) strstr - [(1.5)](#diff.mods.to.declarations-1.5) memchr Subclause [[cstring.syn]](cstring.syn "27.5.1 Header synopsis") describes the changes[.](#diff.mods.to.declarations-1.sentence-2) [2](#diff.mods.to.declarations-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3782) Header [](cwchar.syn#header:%3ccwchar%3e "28.7.3 Header synopsis [cwchar.syn]"): The following functions have different declarations: - [(2.1)](#diff.mods.to.declarations-2.1) wcschr - [(2.2)](#diff.mods.to.declarations-2.2) wcspbrk - [(2.3)](#diff.mods.to.declarations-2.3) wcsrchr - [(2.4)](#diff.mods.to.declarations-2.4) wcsstr - [(2.5)](#diff.mods.to.declarations-2.5) wmemchr Subclause [[cwchar.syn]](cwchar.syn "28.7.3 Header synopsis") describes the changes[.](#diff.mods.to.declarations-2.sentence-2) [3](#diff.mods.to.declarations-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3795) Header [](cstddef.syn#header:%3ccstddef%3e "17.2.1 Header synopsis [cstddef.syn]") declares the names nullptr_t, byte, and to_integer, and the operators and operator templates in [[support.types.byteops]](support.types.byteops "17.2.5 byte type operations"), in addition to the names declared in[](support.c.headers.general#header:%3cstddef.h%3e "17.15.1 General [support.c.headers.general]") in the C standard library[.](#diff.mods.to.declarations-3.sentence-1) ### [C.8.5](#diff.mods.to.behavior) Modifications to behavior [[diff.mods.to.behavior]](diff.mods.to.behavior) #### [C.8.5.1](#diff.mods.to.behavior.general) General [[diff.mods.to.behavior.general]](diff.mods.to.behavior.general) [1](#diff.mods.to.behavior.general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3806) Header [](cstdlib.syn#header:%3ccstdlib%3e "17.2.2 Header synopsis [cstdlib.syn]"): The following functions have different behavior: - [(1.1)](#diff.mods.to.behavior.general-1.1) atexit - [(1.2)](#diff.mods.to.behavior.general-1.2) exit - [(1.3)](#diff.mods.to.behavior.general-1.3) abort Subclause [[support.start.term]](support.start.term "17.5 Startup and termination") describes the changes[.](#diff.mods.to.behavior.general-1.sentence-2) [2](#diff.mods.to.behavior.general-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3817) Header [](csetjmp.syn#header:%3ccsetjmp%3e "17.14.3 Header synopsis [csetjmp.syn]"): The following functions have different behavior: - [(2.1)](#diff.mods.to.behavior.general-2.1) longjmp Subclause [[csetjmp.syn]](csetjmp.syn "17.14.3 Header synopsis") describes the changes[.](#diff.mods.to.behavior.general-2.sentence-2) #### [C.8.5.2](#diff.offsetof) Macro offsetof(*type*, *member-designator*) [[diff.offsetof]](diff.offsetof) [1](#diff.offsetof-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3829) The macro offsetof, defined in[](cstddef.syn#header:%3ccstddef%3e "17.2.1 Header synopsis [cstddef.syn]"), accepts a restricted set of *type* arguments in C++[.](#diff.offsetof-1.sentence-1) Subclause [[support.types.layout]](support.types.layout "17.2.4 Sizes, alignments, and offsets") describes the change[.](#diff.offsetof-1.sentence-2) #### [C.8.5.3](#diff.malloc) Memory allocation functions [[diff.malloc]](diff.malloc) [1](#diff.malloc-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3837) The functionsaligned_alloc,calloc,malloc, andrealloc are restricted in C++[.](#diff.malloc-1.sentence-1) Subclause [[c.malloc]](c.malloc "20.2.12 C library memory allocation") describes the changes[.](#diff.malloc-1.sentence-2)