标签:c++枚举转换为字符串
enum EM_DEMO
{
EM_INDEX1 = 1,
EM_INDEX2 = 2,
EM_INDEX3 = 3,
EM_INDEX4 = 4
}
//多字节
#define _TXT__(x) #x
#define EMTOSTR(EM) _TXT__(EM)
//多字节或 unicode
#define _TXT__(x) _T(#x)
#define EMTOSTR(EM) _TXT__(EM)
//调用案例
if ( _tcscmp( _T("EM_INDEX1"),EMTOSTR(EM_INDEX1) ) == 0 )
{
;//UNICODE调用
}
if ( strcmp( "EM_INDEX1", EMTOSTR(EM_INDEX1) ) == 0 )
{
;//多字节调用
}
标签:c++枚举转换为字符串
原文地址:http://blog.csdn.net/wclaccp/article/details/26668745