Annex C (informative) Compatibility [diff]

C.4 C standard library [diff.library]

This subclause summarizes the contents of the C++ standard library included from the Standard C library. It also summarizes the explicit changes in definitions, declarations, or behavior from the Standard C library noted in other subclauses ([headers], [support.types], [c.strings]).

The C++ standard library provides 57 standard macros from the C library, as shown in Table [tab:diff.standard.macros].

The header names (enclosed in < and >) indicate that the macro may be defined in more than one header. All such definitions are equivalent ([basic.def.odr]).

Table 150 — Standard macros
assert HUGE_VAL NULL <cstring> SIGINT va_end
BUFSIZ LC_ALL NULL <ctime> SIGSEGV va_start
CLOCKS_PER_SEC LC_COLLATE NULL <cwchar> SIGTERM WCHAR_MAX
EDOM LC_CTYPE offsetof SIG_DFL WCHAR_MIN
EILSEQ LC_MONETARY RAND_MAX SIG_ERR WEOF <cwchar>
EOF LC_NUMERIC SEEK_CUR SIG_IGN WEOF <cwctype>
ERANGE LC_TIME SEEK_END stderr _IOFBF
errno L_tmpnam SEEK_SET stdin _IOLBF
EXIT_FAILURE MB_CUR_MAX setjmp stdout _IONBF
EXIT_SUCCESS NULL <clocale> SIGABRT TMP_MAX
FILENAME_MAX NULL <cstddef> SIGFPE va_arg
FOPEN_MAX NULL <cstdlib> SIGILL va_copy

The C++ standard library provides 57 standard values from the C library, as shown in Table [tab:diff.standard.values].

Table 151 — Standard values
CHAR_BIT FLT_DIG INT_MIN MB_LEN_MAX
CHAR_MAX FLT_EPSILON LDBL_DIG SCHAR_MAX
CHAR_MIN FLT_MANT_DIG LDBL_EPSILON SCHAR_MIN
DBL_DIG FLT_MAX LDBL_MANT_DIG SHRT_MAX
DBL_EPSILON FLT_MAX_10_EXP LDBL_MAX SHRT_MIN
DBL_MANT_DIG FLT_MAX_EXP LDBL_MAX_10_EXP UCHAR_MAX
DBL_MAX FLT_MIN LDBL_MAX_EXP UINT_MAX
DBL_MAX_10_EXP FLT_MIN_10_EXP LDBL_MIN ULONG_MAX
DBL_MAX_EXP FLT_MIN_EXP LDBL_MIN_10_EXP USHRT_MAX
DBL_MIN FLT_RADIX LDBL_MIN_EXP
DBL_MIN_10_EXP FLT_ROUNDS LONG_MAX
DBL_MIN_EXP INT_MAX LONG_MIN

The C++ standard library provides 20 standard types from the C library, as shown in Table [tab:diff.standard.types].

Table 152 — Standard types
clock_t ldiv_t size_t <cstdio> va_list
div_t mbstate_t size_t <cstdlib> wctrans_t
FILE ptrdiff_t size_t <cstring> wctype_t
fpos_t sig_atomic_t size_t <ctime> wint_t <cwchar>
jmp_buf size_t <cstddef> time_t wint_t <cwctype>

The C++ standard library provides 2 standard structs from the C library, as shown in Table [tab:diff.standard.structs].

Table 153 — Standard structs
lconv tm

The C++ standard library provides 209 standard functions from the C library, as shown in Table [tab:diff.standard.functions].

Table 154 — Standard functions
abort fmod iswalnum modf strlen wcscat
abs fopen iswalpha perror strncat wcschr
acos fprintf iswcntrl pow strncmp wcscmp
asctime fputc iswctype printf strncpy wcscoll
asin fputs iswdigit putc strpbrk wcscpy
atan fputwc iswgraph putchar strrchr wcscspn
atan2 fputws iswlower puts strspn wcsftime
atexit fread iswprint putwc strstr wcslen
atof free iswpunct putwchar strtod wcsncat
atoi freopen iswspace qsort strtok wcsncmp
atol frexp iswupper raise strtol wcsncpy
bsearch fscanf iswxdigit rand strtoul wcspbrk
btowc fseek isxdigit realloc strxfrm wcsrchr
calloc fsetpos labs remove swprintf wcsrtombs
ceil ftell ldexp rename swscanf wcsspn
clearerr fwide ldiv rewind system wcsstr
clock fwprintf localeconv scanf tan wcstod
cos fwrite localtime setbuf tanh wcstok
cosh fwscanf log setlocale time wcstol
ctime getc log10 setvbuf tmpfile wcstombs
difftime getchar longjmp signal tmpnam wcstoul
div getenv malloc sin tolower wcsxfrm
exit getwc mblen sinh toupper wctob
exp getwchar mbrlen sprintf towctrans wctomb
fabs gmtime mbrtowc sqrt towlower wctrans
fclose isalnum mbsinit srand towupper wctype
feof isalpha mbsrtowcs sscanf ungetc wmemchr
ferror iscntrl mbstowcs strcat ungetwc wmemcmp
fflush isdigit mbtowc strchr vfprintf wmemcpy
fgetc isgraph memchr strcmp vfwprintf wmemmove
fgetpos islower memcmp strcoll vprintf wmemset
fgets isprint memcpy strcpy vsprintf wprintf
fgetwc ispunct memmove strcspn vswprintf wscanf
fgetws isspace memset strerror vwprintf
floor isupper mktime strftime wcrtomb

C.4.1 Modifications to headers [diff.mods.to.headers]

For compatibility with the Standard C library, the C++ standard library provides the C headers enumerated in [depr.c.headers], but their use is deprecated in C++.

C.4.2 Modifications to definitions [diff.mods.to.definitions]

C.4.2.1 Types char16_t and char32_t [diff.char16]

The types char16_t and char32_t are distinct types rather than typedefs to existing integral types.

C.4.2.2 Type wchar_t [diff.wchar.t]

wchar_t is a keyword in this International Standard ([lex.key]). It does not appear as a type name defined in any of <cstddef>, <cstdlib>, or <cwchar> ([c.strings]).

C.4.2.3 Header <iso646.h> [diff.header.iso646.h]

The tokens and, and_eq, bitand, bitor, compl, not_eq, not, or, or_eq, xor, and xor_eq are keywords in this International Standard ([lex.key]). They do not appear as macro names defined in <ciso646>.

C.4.2.4 Macro NULL [diff.null]

The macro NULL, defined in any of <clocale>, <cstddef>, <cstdio>, <cstdlib>, <cstring>, <ctime>, or <cwchar>, is an implementation-defined C++ null pointer constant in this International Standard ([support.types]).

C.4.3 Modifications to declarations [diff.mods.to.declarations]

Header <cstring>: The following functions have different declarations:

[c.strings] describes the changes.

C.4.4 Modifications to behavior [diff.mods.to.behavior]

Header <cstdlib>: The following functions have different behavior:

[support.start.term] describes the changes.

Header <csetjmp>: The following functions have different behavior:

[support.runtime] describes the changes.

C.4.4.1 Macro offsetof(type, member-designator) [diff.offsetof]

The macro offsetof, defined in <cstddef>, accepts a restricted set of type arguments in this International Standard. [support.types] describes the change.

C.4.4.2 Memory allocation functions [diff.malloc]

The functions calloc, malloc, and realloc are restricted in this International Standard. [c.malloc] describes the changes.