From: David F on
I am getting the following 2 error messages from the compiler:

f:\development\projects 2005\fc\fc.cpp(296) : error C2664: 'wsprintfW' :
cannot convert parameter 1 from 'LPSTR' to 'LPWSTR'

Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast



f:\development\projects 2005\fc\fc.cpp(373) : error C2664: 'FindFirstFileW'
: cannot convert parameter 1 from 'const char *' to 'LPCWSTR'

Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast


My code does not have "wsprintfW" & "FindFirstFileW" !
What I do have is "wsprintf" & "FindFirstFile".

Anybody heard about such behavior of the C++ compiler?

Thanks,
David


From: Jochen Kalmbach [MVP] on
Hi David!

> My code does not have "wsprintfW" & "FindFirstFileW" !
> What I do have is "wsprintf" & "FindFirstFile".

There is *no* function "wsprintf" and "FindFirstFile"!

There is either an ANSI- or UNICODE-Version, and therefor either
"wsprintfA" or "wsprintfW" ("FindFirstFileA" or "FindFirstFileW").

What you see is just a define which will be set to one of the abouve
depending on the "character set".
By default in VC2005 the default is UNICODE.

To be flexible you should include "tchar.h" and pass your strings in the
following way:

_T("")

Then your string will be correctly passed, regardless of ANSI/UNICODE
setting...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
From: David McCabe on
You have UNICODE defined. When you compile with Unicode, Windows API
functions that take strings resolve to their Unicode variants, which have a
'W' suffix. They then require Unicode strings as parameters.

Either change your strings to be Unicode strings (constants should have an L
prefix), or change your compile options to use "multi-byte character sets".
--
David

"David F" <David-White(a)earthlink.net> wrote in message
news:uRns%23ElcFHA.2696(a)TK2MSFTNGP09.phx.gbl...
>I am getting the following 2 error messages from the compiler:
>
> f:\development\projects 2005\fc\fc.cpp(296) : error C2664: 'wsprintfW' :
> cannot convert parameter 1 from 'LPSTR' to 'LPWSTR'
>
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>
>
>
> f:\development\projects 2005\fc\fc.cpp(373) : error C2664:
> 'FindFirstFileW'
> : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
>
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>
>
> My code does not have "wsprintfW" & "FindFirstFileW" !
> What I do have is "wsprintf" & "FindFirstFile".
>
> Anybody heard about such behavior of the C++ compiler?
>
> Thanks,
> David
>
>


From: Nishant Sivakumar on
You've got UNICODE defined. Remove the definition or convert all your string
literals to Unicode compliant ones.

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com


"David F" <David-White(a)earthlink.net> wrote in message
news:uRns%23ElcFHA.2696(a)TK2MSFTNGP09.phx.gbl...
>I am getting the following 2 error messages from the compiler:
>
> f:\development\projects 2005\fc\fc.cpp(296) : error C2664: 'wsprintfW' :
> cannot convert parameter 1 from 'LPSTR' to 'LPWSTR'
>
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>
>
>
> f:\development\projects 2005\fc\fc.cpp(373) : error C2664:
> 'FindFirstFileW'
> : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
>
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>
>
> My code does not have "wsprintfW" & "FindFirstFileW" !
> What I do have is "wsprintf" & "FindFirstFile".
>
> Anybody heard about such behavior of the C++ compiler?
>
> Thanks,
> David
>
>


From: David Carlsson on
Does your project use Unicode.
This is a snippet from winuser.h where wsprintf is defined

WINUSERAPI
int
WINAPIV
wsprintfA(
OUT LPSTR,
IN LPCSTR,
...);
WINUSERAPI
int
WINAPIV
wsprintfW(
OUT LPWSTR,
IN LPCWSTR,
...);
#ifdef UNICODE
#define wsprintf wsprintfW
#else
#define wsprintf wsprintfA
#endif // !UNICODE

As you can see wsprintf is defined as a macro for wsprintfW och wsprintfA depending on UNICODE or not.

/David


David F wrote:
> I am getting the following 2 error messages from the compiler:
>
> f:\development\projects 2005\fc\fc.cpp(296) : error C2664: 'wsprintfW' :
> cannot convert parameter 1 from 'LPSTR' to 'LPWSTR'
>
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>
>
>
> f:\development\projects 2005\fc\fc.cpp(373) : error C2664: 'FindFirstFileW'
> : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
>
> Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>
>
> My code does not have "wsprintfW" & "FindFirstFileW" !
> What I do have is "wsprintf" & "FindFirstFile".
>
> Anybody heard about such behavior of the C++ compiler?
>
> Thanks,
> David
>
>
 |  Next  |  Last
Pages: 1 2
Prev: LNK2001
Next: URLDownloadToFile