WCHAR and wchar_t 的区别 (zz)

//z 2012-6-28 16:31:32 PM is2120@csdn
在定义了unicode的情况下,wsprintf的格式字符串

c A single character. This sequence is interpreted as type
WCHAR
.
C A single character. This sequence is interpreted as type
CHAR
.

Q:I was wondering if there was any practical difference between WCHAR and wchar_t.

A:
Well, one practical difference would be that WCHAR doesn't exist on my platform. For Windows only (and with no intention of ever porting the program to another platform) and with the necessary headers included, it's the same (sinceWCHAR
is just a typedef).

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 of was simply a typedef forshort

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

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

//z 2012-6-28 16:31:32 PM is2120@csdn

//z 2012-12-03 10:36:01 IS2120@BG57IV3.T3905646052.K[T42,L399,R15,V371]
_T _TEXT L
有什么区别

_T("Text") is a narrow-character (ASCII) literal in an ANSI build but a wide character (UNICODE) literal in a Unicode build.

 L"Text" is always a wide-character literal, regardless of preprocessor definitions.

 _T() is a macro, the L prefix is part of the core C and C++ language lexical structure.

原文链接: https://www.cnblogs.com/IS2120/archive/2012/06/28/6745882.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    WCHAR and wchar_t 的区别 (zz)

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/53805

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月9日 上午5:10
下一篇 2023年2月9日 上午5:10

相关推荐