What does _T stands for in a CString

2019-01-18 18:04发布

What does the "T" represents in a string. For example _T("Hello").I have seen this in projects where unicode support is needed.What it actually tells the processor

3条回答
仙女界的扛把子
2楼-- · 2019-01-18 18:21

_T stands for “text”. It will turn your literal into a Unicode wide character literal if and only if you are compiling your sources with Unicode support. See http://msdn.microsoft.com/en-us/library/c426s321.aspx.

查看更多
叛逆
3楼-- · 2019-01-18 18:28

From MSDN:

Use the _T macro to code literal strings generically, so they compile as Unicode strings under Unicode or as ANSI strings (including MBCS) without Unicode

查看更多
狗以群分
4楼-- · 2019-01-18 18:37

It's actually used for projects where Unicode and ANSI support is required. It tells the compiler to compile the string literal as either Unicode or ANSI depending on the value of a precompiler define.

Why you would want to do this is another matter. If you want to support Unicode by itself then just write Unicode, in this case L"Hello". The _T() macro was added when you needed to support Windows NT and later (which support Unicode) and Windows 9x/ME (which do not). These days any code using these macros is obsolete, since all modern Windows versions are Unicode-based.

查看更多
登录 后发表回答