vs2008编译的问题

本文介绍了解决在Visual Studio 2008中由于UnicodeCharacter与Multi-ByteCharacter不匹配导致的编译错误的方法。通过调整项目的字符集设置,可以有效避免此类错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Unicode Character与Multi-Byte Character
2008-11-13 13:40

编译时出现很多错误:

d:/visual studio 2008/projects/teapot/teapot/d3dutility.cpp(37) : error C2440: '=' : cannot convert from 'const char [13]' to 'LPCWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:/visual studio 2008/projects/teapot/teapot/d3dutility.cpp(41) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [25]' to 'LPCWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:/visual studio 2008/projects/teapot/teapot/d3dutility.cpp(49) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [13]' to 'LPCWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:/visual studio 2008/projects/teapot/teapot/d3dutility.cpp(53) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [24]' to 'LPCWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
d:/visual studio 2008/projects/teapot/teapot/d3dutility.cpp(73) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [27]' to 'LPCWSTR'
       

 

解决方法如下:

中文版VC++2005(8.0):项目->属性->配置属性->常规->字符集:把使用 Unicode 字符集改成使用多字节字符集

英文版VC++2008(9.0):Project->Properties->General->Character Set:将Use Unicode Character Set改为Use Multi-Byte Character Set

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值