I'll start by saying I know basically nothing about wide strings and Unicode support. I let QString and QFile handle that for me 99% of the time, but I'm trying to compile someone else's library written for VC6.
When I compile with MSVC2010 in Qt Creator I get this error:
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
The code is using the FindFirstFile
function, which is overloaded (sort of) depending on whether you're compiling with the Unicode character set. I don't understand what type FindFirstFile
is expecting, when the input for FindFirstFileA and FindFirstFileW seems to be two completely different types.
So here's my question: What is the expected input type for FindFirstFile
?
Corollary: How do I take a filename of type const char*
and put it into a form that FindFirstType will accept?
L
doesn't help. – PhluciousUNICODE
preprocessor symbol (you probably don't), replace the call withFindFirstFile(_T("arg_0"), ...)
. Otherwise, replace the call withFindFirstFileW(L"arg_0", ...)
. To answer your question, the expected argument type isconst char *
if you're callingFindFirstFileA
andconst wchar_t *
if you're callingFindFirstFileW
. – PraetorianTCHAR
s. Use wide strings from the beginning and it's a lot less to worry about and will work in any version of Windows that's not really really old. – chris