关于VC2008编译出现错误“error C2664: ” 的处理方法:

VC2008 中编程如下:  

TempValue.Format("%d" ,m_CH1_Value);  // TempValue Cstring 类型,m_CH1_ValueInt 类型

编译之后出现

1>e:\project\cplus\control\control\controldlg.cpp(200) : error C2664: void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...): 不能将参数1 从“const char [3] ”转换为“const wchar_t *

1>        with

1>        [

1>            BaseType=wchar_t,

1>            StringTraits=StrTraitMFC_DLL<wchar_t>

1>        ]

1>        与指向的类型无关;转换要求reinterpret_castC 样式转换或函数样式转换

1> 正在生成代码...

1> 生成日志保存在“file://e:\Project\CPlus\Control\Control\Debug\BuildLog.htm

1>Control - 1 个错误,0 个警告

经过分析,发现是项目定义问题,开始在建立项目的时候,选择了字符集为:Unicode,选择成多字节字符集即可解决这个编译错误。

原文地址:https://www.cnblogs.com/dongzhiquan/p/1994577.html