Why is VC++ 2005 beta2 telling me this

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2004
Posts: 140
Reputation: Mahen is an unknown quantity at this point 
Solved Threads: 2
Mahen Mahen is offline Offline
Junior Poster

Why is VC++ 2005 beta2 telling me this

 
0
  #1
Aug 16th, 2005
Why is VC++ 2005 beta2 telling me this and how do I solve it.



.\Test2.cpp(42) : error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast




Please note that this problem does not exist in VC++ 6.0
Want a new website for free:
http://indigo.kjots.com/
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 62
Reputation: freemind is an unknown quantity at this point 
Solved Threads: 1
freemind's Avatar
freemind freemind is offline Offline
Junior Poster in Training

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #2
Aug 16th, 2005
The documentation of your compiler keeps the answers to many "secrets". Besides ALPHA and BETA releases of programs carry these names for the sole reason to say that they are still unfinished.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 164
Reputation: Stoned_coder is an unknown quantity at this point 
Solved Threads: 5
Stoned_coder Stoned_coder is offline Offline
Junior Poster

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #3
Aug 16th, 2005
lpcWstr erm wide char type.
char* narrow char type.
There is no relationship between the two types whatsoever therefore static_cast<> cant do it. You must use reinterpret_cast<>. It is only portable and safe if you then use reinterpret_cast<> back to LPCWSTR before using it.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 140
Reputation: Mahen is an unknown quantity at this point 
Solved Threads: 2
Mahen Mahen is offline Offline
Junior Poster

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #4
Aug 17th, 2005
Originally Posted by Stoned_coder
lpcWstr erm wide char type.
char* narrow char type.
There is no relationship between the two types whatsoever therefore static_cast<> cant do it. You must use reinterpret_cast<>. It is only portable and safe if you then use reinterpret_cast<> back to LPCWSTR before using it.


AM sorry but i cannot understand it, can u be more clear
Want a new website for free:
http://indigo.kjots.com/
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #5
Aug 17th, 2005
who is "u"?
who is "i"?

Use real English in writing and you might understand what others write as well.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #6
Aug 17th, 2005
Post the code. It's likely the function expects 'CString' and you are passing it a char *.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 140
Reputation: Mahen is an unknown quantity at this point 
Solved Threads: 2
Mahen Mahen is offline Offline
Junior Poster

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #7
Aug 17th, 2005
Originally Posted by winbatch
Post the code. It's likely the function expects 'CString' and you are passing it a char *.

i use it lik that:

FindFirstFile("where.exe", blah blah);
Want a new website for free:
http://indigo.kjots.com/
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #8
Aug 17th, 2005
Post the actual code.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 164
Reputation: Stoned_coder is an unknown quantity at this point 
Solved Threads: 5
Stoned_coder Stoned_coder is offline Offline
Junior Poster

Re: Why is VC++ 2005 beta2 telling me this

 
0
  #9
Aug 17th, 2005
look the problem is this simple. You are calling a function that expects a LPCWSTR but you are passing char*. So to fix either pass a LPCWSTR (long pointer to a constant WIDE string) i.e. a unicode string or use the correct function for char*.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC