pw_protobuf: Break the ambiguity for spans in generated code
Some std::span implementations has an ambiguity in the resolving
(ptr, 0) span construction. This CL adds explicit size_t for the second
arg to avoid it.
Change-Id: Ib2e0c3319a5841f64981d7f4c5d62b5d3dea8ebd
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/99285
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Pigweed-Auto-Submit: Dennis Kormalev <denk@google.com>
diff --git a/pw_protobuf/py/pw_protobuf/codegen_pwpb.py b/pw_protobuf/py/pw_protobuf/codegen_pwpb.py
index 36101a3..f5c53dd 100644
--- a/pw_protobuf/py/pw_protobuf/codegen_pwpb.py
+++ b/pw_protobuf/py/pw_protobuf/codegen_pwpb.py
@@ -2124,9 +2124,10 @@
output.write_line('};')
output.write_line('PW_MODIFY_DIAGNOSTICS_POP();')
- output.write_line('inline constexpr std::span<const {}::MessageField> '
- 'kMessageFields = {{ _kMessageFields, {} }};'.format(
- PROTOBUF_NAMESPACE, len(properties)))
+ output.write_line(
+ 'inline constexpr std::span<const {}::MessageField> '
+ 'kMessageFields = {{ _kMessageFields, size_t({}) }};'.format(
+ PROTOBUF_NAMESPACE, len(properties)))
output.write_line(f'}} // namespace {namespace}')