Why was wchar_t invented?

前端 未结 10 1704
说谎
说谎 2021-01-03 20:15

Why is wchar_t needed? How is it superior to short (or __int16 or whatever)?

(If it matters: I live in Windows world. I don\'t

10条回答
  •  日久生厌
    2021-01-03 20:54

    The reason there's a wchar_t is pretty much the same reason there's a size_t or a time_t - it's an abstraction that indicates what a type is intended to represent and allows implementations to chose an underlying type that can represent the type properly on a particular platform.

    Note that wchar_t doesn't need to be a 16 bit type - there are platforms where it's a 32-bit type.

提交回复
热议问题