Annex C (informative) Compatibility [diff]

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

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

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

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

C.3.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.3.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.3.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.3.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.3.3 Modifications to declarations [diff.mods.to.declarations]

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

[c.strings] describes the changes.

C.3.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.3.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.3.4.2 Memory allocation functions [diff.malloc]

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