使用VS2005,开头就受挫!error C2664

在VS2005里写个最简单的语句

MessageBox("Hello,World!");

出现错误提示:

error C2664: ‘CWnd::MessageBoxW’ : cannot convert parameter 1 from ‘const char [13]’ to ‘LPCTSTR’

查找到解决方法是改成

MessageBox(_T("Hello,World!"));

因为2005中默认的是unicode的,char是非unicode的。不同于以前在6.0中的写法

MessageBox("Hello,World!")

 

可以在VS2005项目属性中改变设置 General->Character Set->Not Set

 

扩展阅读:
Unicode Programming Summary
http://msdn.microsoft.com/en-us/library/dybsewaf%28VS.80%29.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.