In the midsts of moving to C++20 for a Win32 project in VS 2019. We have code that looks like:
m_wndWindow.Create(m_hwnd, CRect(0,0, 100, 100), ....);
This used to work, but now we're getting C2664 errors stating that CRect
cannot be converted to ATL::_U_RECT
. We've found that the error goes away if we change to the following:
auto rec = CRect(0,0,100,100);
m_wndWindow.Create(m_hwnd, rec, .....);
or
m_wndWindow.Create(m_hwnd, (LPRECT)CRect(0,0, 100, 100), ....);
It makes no sense to me that the first one works, though the second one makes sense because CRect
has a user defined converter to LPRECT.
I'm not sure if this is due to a change how parameters are initialized in c++20, or if there is an issue with VS 2019.
We haven't upgraded to VS 2022, and I'm wondering if this is fixed, I'll wait till we upgrade to 2022 before trying to move to C++20.
Am I missing something?