From 91e14de1f7c0a208fb0275bb18a4dd4191d757ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 18 Jun 2025 18:05:38 +0200 Subject: [PATCH] ortools: utils: keep compatibility with protobuf < 26 --- ortools/util/file_util.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ortools/util/file_util.cc b/ortools/util/file_util.cc index 6ee86f6e52..62d0aaa314 100644 --- a/ortools/util/file_util.cc +++ b/ortools/util/file_util.cc @@ -166,7 +166,11 @@ absl::Status WriteProtoToFile(absl::string_view filename, case ProtoWriteFormat::kJson: { google::protobuf::util::JsonPrintOptions options; options.add_whitespace = true; +#if PROTOBUF_VERSION >= 5026000 // Version 26.0.0 options.always_print_fields_with_no_presence = true; +#else + options.always_print_primitive_fields = true; +#endif options.preserve_proto_field_names = true; if (!google::protobuf::util::MessageToJsonString(proto, &output_string, options)