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

Fix #5874: Use of designated initializers fails Windows build #5875

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

definability
Copy link

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

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

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:

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;
};

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;
};

@definability definability changed the title Fix #5874: Use of designated initializers requires C++20 fails the build Fix #5874: Use of designated initializers fails Windows build Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant