编译过程中出现如下错误:不能将参数 1 从“const wchar_t *”转换为“std::string”
出错代码如下:
CString csFileName = GetDocument()->GetFileName();
mOSG->InitOSG(csFileName.GetString());
InitOSG的函数原型如下:
void cOSG::InitOSG(std::string modelname);
原因:
ANSI和UNICODE的区别就是
ANSI编码CString默认是窄字节的
UNICODE默认是宽字节的
std::string总是窄字节的
所以UNICODE下你要做宽窄字节转换
USES_CONVERSION;
std::string str=W2A(csFileName.GetBuffer());
mOSG->InitOSG(str);
ok了