Is wchar_t just a typedef of unsigned short?

前端 未结 6 674
滥情空心
滥情空心 2020-12-11 14:54

for example, does:

wchar_t x;

translate to:

unsigned short x;
6条回答
  •  再見小時候
    2020-12-11 15:24

    wchar_t isn't required by the standard to be unsigned. It can also be signed. And there must be another type of the same size; but the standard doesn't explicitly say that that other type must be short.

    "the same size, signedness, and alignment requirements as one of the other integral types, called its underlying type" (C++98 §3.9.1).

    In C compilers this is a typedef, usually defined in stddef.h

提交回复
热议问题