This appears related to #293. There's something weird going on, and I can't compile WTL v10 as of now because of it. I have a gut feeling that it has something to do with VS2019, but I can't say for sure right now.
Currently, compiling my app with WTL gives a whole bunch of errors about ATL::CString:
C2039 'CString': is not a member of 'ATL' windirstat ...\wtl.10.0.8280\lib\native\include\atlwinx.h
As best as I can tell, there is no CString
in the ATL namespace - only CStringT
(the base template class)... whereas in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\atlmfc\include\afxstr.h:103
there's this:
typedef ATL::CStringT< wchar_t, StrTraitMFC< wchar_t > > CStringW; typedef ATL::CStringT< char, StrTraitMFC< char > > CStringA; typedef ATL::CStringT< TCHAR, StrTraitMFC< TCHAR > > CString;
Which is presumably what you want. Since CString here is typedef
d outside the ATL namespace, it won't work.
I've tried a simple/ugly using ATL::CString = ATL::CStringT< TCHAR, StrTraitMFC< TCHAR > >;
, and the more complex/ugly:
namespace ATL { using CString = ATL::CStringT< TCHAR, StrTraitMFC< TCHAR > >; }
and many variations thereof in my headers, but it's not working. So the fix isn't really simple, and I'll have to revert for now.
Anonymous
There must be something wrong with your setup or your project. I don't see that with VS2019 or older VS/ATL.
afxstr.h is for MFC, you will find typedef for ATL in atlstr.h:
typedef CAtlString CString;
Please provide more info about what is going on.
Aha! Now we're getting somewhere. In that file the code is:
```
#ifndef _AFX
typedef CAtlStringW CStringW;
ifdef _ATL_USE_WINAPI_FAMILY_DESKTOP_APP
typedef CAtlStringA CStringA;
endif // _ATL_USE_WINAPI_FAMILY_DESKTOP_APP
typedef CAtlString CString;
endif
`` However, since I'm plugging this into a mostly MFC application (because I hate MFC),
_AFXis defined. In the long run, this should be fixed, but in the meantime, should I just
#undef _AFX` (or will that break everything else?)Ah, I didn't know that you are actually using MFC. In that case you need to add this line before including atlapp.h:
namespace ATL { using ::CString; };
The compiler will now be able tu use MFC's CString as ATL::CString
Cheers,
Nenad