Preferred include header for std :: size_t

std::size_t defined in any of: <cstddef> <cstdio> <cstdlib> <cstring> <ctime> <cwchar>

What is considered kosher to get all std::size_t ?

+6
source share
1 answer

Since this is part of the C library, I think the standard standard C header is correct: stddef.h , i.e. cstddef

From C11:

7.19 General definitions

The header defines the following macros and declares the following types. Some of them are also defined in other headings, as indicated in their respective subclauses.

[...] size_t , which is the unsigned integer of the result, sizeof operator;

This is still a C ++ question, so I think the quote from the C ++ standard is more appropriate:

18.2 Types

Table 30 describes the <cstddef> header.

Types: ptrdiff_t size_t max_align_t nullptr_t

+9
source

Source: https://habr.com/ru/post/980008/


All Articles