Any Idea how to fix? Would be really useful. I tried changing conformance mode to off and it worked but the other parts of the program failed. Any other fixes?
Line that has problem :
RecursiveDelete(path, L"desktop.ini");
Edit :
The program is to change windows registry files and is connected with my c++ loader. When the project is standalone not connected to the loader it works perfectly fine.
The
RecursiveDelete()function takes 2LPWSTRparameters.LPWSTRis an alias forwchar_t*, ie a pointer to non-constwchar_tdata. However, a string literal isconstdata, in this caseL"desktop.ini"is aconst wchar_t[12](including the null terminator), which decays into aconst wchar_t*pointer. You can't use apointer-to-constwhere apointer-to-non-constis expected, that is what the error message is complaining about.IF the function DOES NOT alter the contents of its second parameter, then that parameter should be implemented as a
pointer-to-const, eg:(aka
void RecursiveDelete(wchar_t*, const wchar_t*);).If changing the declaration of the function is not an option (ie, it is from an existing API, etc), you could instead cast away the string literal's constness using
const_cast(be VERY CAREFUL doing this!), eg:However, making a non-const duplicate of the string literal's data would be much safer, eg: