I've often wondered why C++ went with the name wchar_t
instead of simply wchar
, and I've never been able to find an answer. Search engines are no help because they think I'm asking about Windows' WCHAR type. Any ideas?
views:
472answers:
2That's a legacy from C, where wchar_t is a typedef, and typedefs have that suffix in the C Standard Library.
The C standard library has used the _t
suffix for many of the types that are defined in the library (as opposed to the types that are baked into C itself as keywords).
For example, there's time_t
, wchar_t
, uint32_t
, size_t
, ptrdiff_t
, div_t
, etc.
Of interest (to me anyway) is that the C standard doesn't reserve names of that form for itself. The C standard does indicate that names that start with "str
", "mem
", and a few other prefixes might be added to the standard in the future, but it doesn't do the same with names that end in "_t
" - except that names that start with "int
" or "uint
" and end with "_t
" might be added to <stdint.h>
in the future. However, POSIX does reserve all names that end in "_t
".