Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of designated initializers fails Windows build #5874

Open
definability opened this issue Mar 2, 2025 · 1 comment
Open

Use of designated initializers fails Windows build #5874

definability opened this issue Mar 2, 2025 · 1 comment
Assignees
Labels
legacy:hands Hand tracking/gestures/etc os:windows MediaPipe issues on Windows platform:c++ Issues specific to C++ framework in mediapipe type:build/install For Build and Installation issues

Comments

@definability
Copy link

definability commented Mar 2, 2025

OS Platform and Distribution

Windows 11

Compiler version

MSVC 19.29.30158 for x64

Programming Language and version

C++17

Installed using virtualenv? pip? Conda?(if python)

No

MediaPipe version

master (ffe429d)

Bazel version

6.5.0

XCode and Tulsi versions (if iOS)

N/A

Android SDK and NDK versions (if android)

N/A

Android AAR (if android)

None

OpenCV version (if running on desktop)

3.4.12

Describe the problem

Build of hand_tracking_cpu example fails

bazel-6.5.0 build --verbose_failures -c opt --define MEDIAPIPE_DISABLE_GPU=1 --define=xnn_enable_avxvnniint8=false --shell_executable="C:\msys64\usr\bin\bash.exe" --repo_env=HERMETIC_PYTHON_VERSION=3.11 -- //mediapipe/examples/desktop/hand_tracking:hand_tracking_cpu

The problem was introduced in

monitoring_info_vector.emplace_back(OutputStreamMonitoringInfo(
{.stream_name = DebugStreamName(id),
.num_packets_added = stream->NumPacketsAdded(),
.next_timestamp_bound = stream->NextTimestampBound()}));
}

Designated initializers are a feature of C++20: https://en.cppreference.com/w/cpp/language/aggregate_initialization.

I see two ways to fix this problem, but I am unsure about the MediaPipe team's plans.

  1. Do not use designated initializers.
  2. Update the C++ version to C++20. This may require updating the codebase accordingly, and people using older compilers may have problems with it.

Complete Logs

All you need to know:

mediapipe/framework/output_stream_handler.cc(146): error C7555: use of designated initializers requires at least '/std:c++20'
@definability definability added the type:build/install For Build and Installation issues label Mar 2, 2025
@definability definability changed the title Use of designated initializers requires C++20 Use of designated initializers requires C++20 fails the build Mar 2, 2025
definability added a commit to definability/mediapipe that referenced this issue Mar 2, 2025
…0 fails the build

Designated initializers are a feature of C++20:
https://en.cppreference.com/w/cpp/language/aggregate_initialization.
However, they appeared in
https://github.com/google-ai-edge/mediapipe/blob/ffe429d5278b914c44fdb5df3ce38962b55580bb/mediapipe/framework/output_stream_handler.cc#L145-L149

The project uses C++17 and adapting it for C++20 would be non-trivial.
The easiest fix is to avoid using aggregated initialization.
It is fine while the order of members is preserved:
```cpp
struct OutputStreamMonitoringInfo {
  std::string stream_name;
  // The total number of packets added to the output stream.
  int num_packets_added;
  // The next timestamp bound of the output stream.
  Timestamp next_timestamp_bound;
};
```
https://github.com/google-ai-edge/mediapipe/blob/eecf8a5696d5e47edbd3b6e99a6064c99f9ab1a4/mediapipe/framework/output_stream_handler.h#L53-L59
@definability
Copy link
Author

definability commented Mar 2, 2025

If the simple solution is satisfactory, please check out my pull request #5875

@definability definability changed the title Use of designated initializers requires C++20 fails the build Use of designated initializers fails Windows build Mar 2, 2025
definability added a commit to definability/mediapipe that referenced this issue Mar 2, 2025
@kuaashish kuaashish added os:windows MediaPipe issues on Windows legacy:hands Hand tracking/gestures/etc platform:c++ Issues specific to C++ framework in mediapipe labels Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy:hands Hand tracking/gestures/etc os:windows MediaPipe issues on Windows platform:c++ Issues specific to C++ framework in mediapipe type:build/install For Build and Installation issues
Projects
None yet
Development

No branches or pull requests

2 participants