CPlusPlus中如何把__FUNCTION__, __FILE__ 宏转化成wchar_t(unicode)类型

写代码的时候遇到个小问题,需要把__FUNCTION__宏变成unicode的类型。
参考了一下VC中_T宏的写法。很简单,不过也许有人并不知道。编译环境VS2008+WinXP

代码
//The code to demonstrate how to convert __FUNCTION__ macro to a unicode string
void FuncChar(char *p){}
void FuncWChar(wchar_t *p){}
int _tmain(int argc, _TCHAR* argv[])
{
//use L for wchar_t
FuncChar("xx");
FuncWChar(L
"xx");

//The __FUNCTION__ marco is char type string
FuncChar(__FUNCTION__);
//FuncWChar(__FUNCTION__); //error C2664: 'FuncWChar' : cannot convert parameter 1 from 'const char [6]' to 'wchar_t *'

#define _L(x) __L(x)
#define __L(x) L##x
FuncWChar( _L(__FUNCTION__) );
//FuncWChar( __L(__FUNCTION__) );error C2065: 'L__FUNCTION__' : undeclared identifier
return 0;
}
原文地址:https://www.cnblogs.com/aoaoblogs/p/1623438.html