c++ - 'CreateDirectoryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' in OpenCV 2.4.5 and VS 2010 -
i trying sample code bagofwords_classification.cpp opencv 2.4.5 visual studio 2010 (vc++ based). found error code :
error c2664: 'createdirectoryw' : cannot convert parameter 1 'const char *' 'lpcwstr'
can me give me solution problem? thanks. :)
update v1:
static void makedir( const string& dir ) { #if defined win32 || defined _win32 createdirectory( dir.c_str(), 0 ); #else mkdir( dir.c_str(), s_irwxu | s_irwxg | s_iroth | s_ixoth ); #endif } static void makeuseddirs( const string& rootpath ) { makedir(rootpath + bowimagedescriptorsdir); makedir(rootpath + svmsdir); makedir(rootpath + plotsdir); }
you have code calls createdirectory
. when unicode
defined, symbol macro createdirectoryw
; intention use "ambiguous" function names when you're using tchar
instead of char
or wchar_t
, can switch between compiling unicode or ansi programs.
however, std::string
doesn't change according unicode
; it's always ansi, c_str
method returns char*
, never wchar_t*
. when have parameter that's ansi, should explicitly call functions ansi, too. in case, call createdirectorya
.
you consider using std::basic_string<tchar>
, that's heading in direction don't wish go.
a quick fix adjust project settings unicode
no longer defined. consult documentation tool set find out how that, or explore ide's project options.
Comments
Post a Comment