From: http://www.mouseos.com/win64/TEXT_T.html
For programming on Windows, strings are often used:
- Text ()Macro
- _ T ()Macro
These two macros are used to classify string constants. In the following code:
Lptstr lpstra =Text("Hello ");
Lptstr lpstrb =_ T("Hello ");
UseText ()And_ T ()The results are the same.
However, they represent two different programming styles:
- Windows programming style
- C/C ++ programming style
The typical meanings of these two styles are:
_ Tchar * Buf = _ T ("hello ");
Or
Lptstr lpbuf = text ("hello ");
Text ()Macro header files defined in WindowsWinnt. h,_ T ()Macro defines the header file of visual VC/C ++Tchar. hTherefore, text () represents the windows programming style, and _ T () represents the C/C ++ style.
InWinnt. hIn the header file, useUnicodeDefinition:
1: #ifdef UNICODE
2: ... ...
3: #define __TEXT(quote) L##quote
4: /* for UNICODE */
5: ... ...
6: #else
7: ... ...
8: #define __TEXT(quote) quote
9: /* for ANSI */
10: ... ...
11: #endif
12: #define TEXT(quote) __TEXT(quote)
Text ()Unicode characters are used when Unicode is defined. Otherwise, ANSI characters are used.
InTchar. hIn the header file, use_ UncodeDefinition:
1: #ifdef _UNICODE
2: ... ...
3: #define __T(x) L##x
4: /* for UNICODE */
5: ... ...
6: #else
7: ... ...
8: #define __T(x) x
9: /* for ANSI */
10: ... ...
11: #endif
12: #define _T(x) __T(x)
In programming, you should always maintain your programming style,SuggestionsYouDo not mixText () and _ T () macros, although the results are the same.
However, for programming on windows, I suggest you alwaysMaintain the windows programming styleTo maintain consistency with the system.
Therefore, we recommend that you useText ()Macro.