Skip to content

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