The error C7555 expands to:
error C7555: use of designated initializers requires at least '/std:c++20'
The Windows Desktop Wizard in Visual Studio 2022 defaults to C++14, so you'll have to change that to C++20 if you wish to take advantage of this language feature. To do so from the IDE, right-click the project, select Properties, and navigate to Configuration Properties -> General. You'll want to set C++ Language Standard to ISO C++20 Standard (/std:c++20).
With that change out of the way, the code compiles as desired.
Not that that's a good thing. There's literally no reason to introduce a preprocessor macro here at all. If you do need to construct a RECT
(or CRect
) from x
, y
, cx
, and cy
, just use a function. And if you do, at least make it work for any x
and y
(not just 0):
inline CRect make_rect(int x, int y, int width, int height) {
return CRect{ x, y, x + width, y + height };
}
Or just use the appropriate CRect
constructor:
inline CRect make_rect(int x, int y, int width, int height) {
return CRect{ POINT{ x, y }, SIZE{ width, height } };
}