-
Notifications
You must be signed in to change notification settings - Fork 6k
[Windows] Reduce Visual Studio build errors caused by keyboard unit tests #49814
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,13 +145,17 @@ class MockMessageQueue { | |
| // Expect the |_target| FlutterKeyEvent has the required properties. | ||
| #define EXPECT_EVENT_EQUALS(_target, _type, _physical, _logical, _character, \ | ||
| _synthesized) \ | ||
| EXPECT_PRED_FORMAT2(_EventEquals, _target, \ | ||
| (FlutterKeyEvent{ \ | ||
| .type = _type, \ | ||
| .physical = _physical, \ | ||
| .logical = _logical, \ | ||
| .character = _character, \ | ||
| .synthesized = _synthesized, \ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This avoids C++20 designated initializers as Visual Studio reports these as build errors.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is awful since I've been using it all over the place in engine...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're building the engine/embedder with clang, so I'd have thought this shouldn't be an issue. This definitely used to be an issue when building with MSVC though, so we can't use it for example in the runner. Has something regressed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, this isn't a regression. Building inside of Visual Studio still works, however, the Visual Studio editor reports errors. I would say it's fine to keep using designated initializers in C++ code. This particular macro is a bit of an exception as it's used pervasively in |
||
| })); | ||
| EXPECT_PRED_FORMAT2( \ | ||
| _EventEquals, _target, \ | ||
| (FlutterKeyEvent{ \ | ||
| /* struct_size = */ sizeof(FlutterKeyEvent), \ | ||
| /* timestamp = */ 0, \ | ||
| /* type = */ _type, \ | ||
| /* physical = */ _physical, \ | ||
| /* logical = */ _logical, \ | ||
| /* character = */ _character, \ | ||
| /* synthesized = */ _synthesized, \ | ||
| /* device_type = */ kFlutterKeyEventDeviceTypeKeyboard, \ | ||
| })); | ||
|
|
||
| #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_TEST_KEYBOARD_H_ | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSVC (Visual Studio's C++ compiler) doesn't expand
__VA_ARGS__well. Instead of "expanding" the__VA_ARGSinto multiple arguments, it places them all into a single argument. This causesEXPECT_EVENT_EQUALSto have unexpected commas while in Visual Studio.