Fixing Wierd Problems

Here's an odd compiler error that I got today while working on a directx sample:

x:\ssargent\projects\introdirectx\chap01\d3dinit.cpp(84) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [19]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Now it turns out this is an error thats partially caused by Visual Studio 2005.  I don't claim to know which is better but apparently code that was written in vs2003 might expect a multi byte character set while VS 2005 defaults to a Unicode character set.  This little error is caused by that difference.  To fix it in vs2005 just switch to a multibyte character set.   Right Click on Project -> Properties -> General -> Character set.   This fixed it for me, perhaps this will help some others.  This was also in this thread: http://www.moon-labs.com/cgi-bin/YaBB/YaBB.cgi?board=book_board;action=display;num=1135734768

Comments

# newbie said:

THANKS!  

I had 111 similar errors, before i made this change.  I was running in debug for a while and as soon as i tried to build in Release in 05 i got all of the errors.  They where in a lot of different places.  Anyway, making the change to Multi Byte fixed the issues.

Tuesday, June 26, 2007 11:48 AM
# Mr.Carrot88 said:

Yes, I have become that grad student. ,

Thursday, October 22, 2009 4:00 PM