Hi

I've just started using Visual C++ 2008. I'd previously being using a
non-MS
compiler.

I get an error:-
error C2664: 'MessageBoxW' : cannot convert parameter 2 from
'const char [22]' to 'LPCWSTR'

for this line
MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);

it then went on to suggest I needed a cast. I'd rather not do that if
I can avoid it

I note that I specified MessageBox() but the error specifies
MessageBoxW().
Have I somehow got some sort of wchar option turned on? I'd always
assumed
MessageBox would take normal C strings.


--
nick keighley

Re: casting by Victor

Victor
Fri Jan 04 08:50:25 CST 2008

Nick Keighley wrote:
> Hi
>
> I've just started using Visual C++ 2008. I'd previously being using a
> non-MS
> compiler.
>
> I get an error:-
> error C2664: 'MessageBoxW' : cannot convert parameter 2 from
> 'const char [22]' to 'LPCWSTR'

You probably have UNICODE defined.

>
> for this line
> MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
>
> it then went on to suggest I needed a cast. I'd rather not do that if
> I can avoid it
>
> I note that I specified MessageBox() but the error specifies
> MessageBoxW().
> Have I somehow got some sort of wchar option turned on? I'd always
> assumed
> MessageBox would take normal C strings.

'MessageBox' is now a macro. The function names are MessageBoxA
and MessageBoxW, IIRC.

Do

MessageBox(NULL, _T("blah"), _T("Note"), MB_OK);

or find and turn off UNICODE.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



Re: casting by Nick

Nick
Fri Jan 04 09:00:17 CST 2008

On 4 Jan, 14:50, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
> Nick Keighley wrote:
> > Hi
>
> > I've just started using Visual C++ 2008. I'd previously being using a
> > non-MS
> > compiler.
>
> > I get an error:-
> > =A0 =A0 error C2664: 'MessageBoxW' : cannot convert parameter 2 from
> > 'const char [22]' to 'LPCWSTR'
>
> You probably have UNICODE defined.
>
>
>
> > for this line
> > =A0 =A0MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK);
>
> > it then went on to suggest I needed a cast. I'd rather not do that if
> > I can avoid it
>
> > I note that I specified MessageBox() but the error specifies
> > MessageBoxW().
> > Have I somehow got some sort of wchar option turned on? I'd always
> > assumed
> > MessageBox would take normal C strings.
>
> 'MessageBox' is now a macro. =A0The function names are MessageBoxA
> and MessageBoxW, IIRC.
>
> Do
>
> =A0 =A0 MessageBox(NULL, _T("blah"), _T("Note"), MB_OK);
>
> or find and turn off UNICODE.

error C3861: '_T': identifier not found

missing header?

--
nick keighley



Re: casting by David

David
Fri Jan 04 09:18:53 CST 2008

Nick Keighley wrote:
> missing header?

<TCHAR.H>

--
David Wilkinson
Visual C++ MVP