1、作为预编译:
#define _UNICODE
#define log()
do
{
_tprintf(_T("%s"), __FILE__ ); --> 可正常使用
}while(0)
2、作为函数
int __cdcel Log::log(const TCHAR *fmt, ...)
{
...
va_list arglist;
va_start(arglist, fmt);
_vstprintf_s_l(msg, 1024, fmt, NULL, arglist);
...
}
Log x;
x.log(_T("%s"), __FILE__ ); ----> 失败
如果在头文件里预定义:
#define __XFILE__ L##__FILE__
x.log(_T("%s"), __XFILE__ ); ----> 失败
如果预定义如下:
#define WFILE2(x) L##x
#define WFILE(x) WFILE2(x)
#define __XFILE__ WFILE(__FILE__)
x.log(_T("%s"), __XFILE__ ); ----> 成功
????????
中文相关: setlocale(LC_CTYPE, "" ) setlocale(LC_CTYPE, "C" )