用_T和没有有什么分别啊??

fan_dtor 2003-01-08 08:46:47
同题!
...全文
98 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
ykj76 2003-01-24
  • 打赏
  • 举报
回复
自己实现就是:
#ifdef _UNICODE
#define _T(x) L##x
#else
#define _T(x) x
#endif
guotuofeng 2003-01-24
  • 打赏
  • 举报
回复
当然有区别:
有_T时,如果编译的版本不是Unicode版本,则该宏将字符串转换为ANSI字符集;如果编译的是Unicode版本则将字符串转换为宽字符集.如果没有_T则所有的字符串都是ANSI字符集
zhouyong0371 2003-01-23
  • 打赏
  • 举报
回复
同意。
详细介绍见《Windows程序设计》P27
英文电子内容如下If the _UNICODE identifier is defined, a macro called __T is defined like this:


#define __T(x) L##x

This is fairly obscure syntax, but it's in the ANSI C standard for the C preprocessor. That pair of number signs is called a "token paste," and it causes the letter L to be appended to the macro parameter. Thus, if the macro parameter is "Hello!", then L##x is L"Hello!".

If the _UNICODE identifier is not defined, the __T macro is simply defined in the following way:


#define __T(x) x

Regardless, two other macros are defined to be the same as __T:


#define _T(x) __T(x)
#define _TEXT(x) __T(x)


Hawk_lp 2003-01-22
  • 打赏
  • 举报
回复
同意

CaptainIII(山上人)!
devil97518 2003-01-22
  • 打赏
  • 举报
回复
yg_xh(果皮) 同意
yg_xh 2003-01-22
  • 打赏
  • 举报
回复
基本和gull1234(俗不可耐)说的一样,
_T 定義 UNICODE 字符串
_T 的應用之時為了程序的可移植性。
写程序时所有字符串都用_T定义,
程序定义了 #define UNICODE 则表示_T是UNICODE字符串;
程序没定义UNICODE则表示_T什么也不代表,_T字符串就是char字符串;
就是说为了编译不同的版本,可以在程序开头定义定义或不定义UNICODE得到不同的字符串
zd_net 2003-01-22
  • 打赏
  • 举报
回复
#define _T(x) __T(x)
#define __T(x) x

_T(x)=x?
gull1234 2003-01-22
  • 打赏
  • 举报
回复
_T 定義 UNICODE 字符串
_T 的應用之時為了程序的可移植性。
菜牛 2003-01-22
  • 打赏
  • 举报
回复
如果定义了UNICODE,就转换为Unicode,否则不变。
shesh 2003-01-09
  • 打赏
  • 举报
回复
区别还是有的.

你跟踪一下内存就知道了.

_T()后,一个"a"变成两字节了.
CaptainIII 2003-01-08
  • 打赏
  • 举报
回复
和_TEXT的含义一样,tchar.h定义的宏,用来说明定义的是一个unicode编码的字符串,不用就是传统的char8位字符。

2,586

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧