I am having a problem trying to use C++20 with Visual Studio 2022:
For example:
CA2CTCW2TCA2W
error C2440: 'initializing': cannot convert from
ATL::CA2WtoATL::CStringT<wchar_t,StrTraitMFC<wchar_t,ATL::ChTraitsCRT<wchar_t>>>
If I revert to C++17 it is fine.
Why is this?
Here is an example:
CLSID AppCLSID ;
if (SUCCEEDED(::CLSIDFromProgID(CT2W(rstrProgID), &AppCLSID) ) )
{
LPOLESTR pszName = NULL ;
if (SUCCEEDED(::ProgIDFromCLSID(AppCLSID, &pszName) ) )
{
CString strAppID = CW2T(pszName);
}
}
Note that rStrProgId could be values like _T("Word.Application").
The above scpecific case the error is:
error C2440: 'initializing': cannot convert from
ATL::CW2WtoATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t>>>
Other code snippets as examples:
Example 2
CString strCalendarName = CA2CT(pName->GetText(), CP_UTF8);
(the value of pName->GetText() is const char *).
Update
Doing what @Inspectable says resolves the one issue.
The others (examples) that won't compile are:
std::string s1 = CT2A(strNameText);
CString strStudent1 = CA2CT(pElement1->GetText(), CP_UTF8);
There are other compiling issues but I feel they are outside the scope of this question.