gpt4 book ai didi

c++ - 为什么类型关键字以 "_t"后缀结尾?

转载 作者:行者123 更新时间:2023-11-30 01:37:40 27 4
gpt4 key购买 nike

我知道 size_t_t 后缀,因为它的别名/typedef。但是我不明白为什么 char16_t, char32_twchar_t 包含 _t 后缀。

最佳答案

对于 wchar_t :

In C++, wchar_t is a distinct fundamental type (and thus it is not defined in <cwchar> nor any other header).

In C, this is a typedef of an integral type.

对于 char16_tchar32_t , 在 <cuchar> / uchar.c 中定义:

In C, this header defines two macros: char16_t and char32_t, which map to unsigned integral types of the appropriate size (the same as uint_least16_t and uint_least32_t, respectively).

In C++, char16_t and char32_t are fundamental types (and thus this header does not define such macros in C++).

因此,在这两种情况下,即使它们是 C++ 中的基本类型,它们仍保留 _t为了与 C 兼容,它们是 typedef 或宏。

关于c++ - 为什么类型关键字以 "_t"后缀结尾?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49254432/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com