Char ipv. LPCWSTR
Hi, i'm not really experianced in C++... well in my sight :)
i never used the VS compiler before. but now i'm cant work without it anymore.
My problem is that i had a lot of code, who all worked with the char parameters, like:MessageBox(NULL,"test","test", 1);This is under a Win32 empty project.
Now he keeps saying, "cost char[5] cant convert to LPCWSTR"
My question is, if there is a option for still using the char parameters, or else a macro or something to make LPCWSTR easy...
i hope this was readeble, because my english isnt any good.
Thanks already!
-Koen
[736 byte] By [
Polity4h] at [2007-12-16]
The LPCWSTR in the error message implies that you compile your code for unicode, so the functions expect wide chars instead of chars. There're two ways to fix this error: the first is to use L"Foo" instead of "Foo" for each string literal (or for strings that need to be wide chars irrelevant of compiling mode). The other possibility is to use _T("Foo") which will prefix the literal with L modifier if required.
hth,
-- b.gr
It is suggessted that you wrap all literals in a _T("") or _TEXT("") macro (they're the same), and use TCHAR instead of char/wchar_t expliciately. This will take a step to making the code compile under all character-size situations.
If this is not an option (lots of code, little time), you can turn off Unicode by going to Project->Properties->General->Character Set and setting the value to "Not Set". This will make everything ASCII again.
However, the TCHAR and _T() approch is recommended.