What is the difference between 'WCHAR' and 'wchar_t'?

后端 未结 5 829
执笔经年
执笔经年 2021-02-05 06:22

Is there any practical difference between WCHAR and wchar_t?

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 07:11

    wchar_t is a distinct type, defined by the C++ standard.

    WCHAR is nonstandard, and as far as I know, exists only on Windows. However, it is simply a typedef (or possibly a macro) for wchar_t, so it makes no practical difference.

    Older versions of MSVC did not have wchar_t as a first-class type—instead it was simply a typedef for short

    Most likely, Microsoft introduced WCHAR to represent a "wide character type" across any compiler version, whether or not wchar_t existed as a native type.

    You should use wchar_t in your code though. That's what it's for.

提交回复
热议问题