Fix compilation with newer protobuf versions#166
Fix compilation with newer protobuf versions#166tippfehlr wants to merge 1 commit intoUltimaker:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to restore build compatibility with newer Protobuf compiler/importer APIs by updating the local hashing helper to use std::string_view and updating the custom Protobuf MultiFileErrorCollector override to the newer RecordError/string_view-based signature.
Changes:
- Updated
hash()to acceptstd::string_viewand adjusted internal usage accordingly. - Renamed/updated the Protobuf error-collector override from
AddError(...)toRecordError(...)usingabsl::string_view.
Comments suppressed due to low confidence (1)
src/MessageTypeStore.cpp:12
absl::string_viewis used in theRecordErrorsignature, but this file doesn’t include the Abseil header that defines it. Relying on transitive includes from protobuf headers is brittle; please include the appropriate Abseil header explicitly (e.g., the one that definesabsl::string_view) so this TU compiles regardless of protobuf’s internal include structure.
#include <string_view>
#include <unordered_map>
#include <google/protobuf/compiler/importer.h>
#include <google/protobuf/dynamic_message.h>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| void RecordError(absl::string_view filename, int line, int column, absl::string_view message) override | ||
| { |
There was a problem hiding this comment.
The error collector override was renamed to RecordError(absl::string_view, ...), which likely won’t compile with the currently pinned protobuf version in this repo (protobuf/3.21.12 in conanfile.py). To keep builds working, either bump the protobuf requirement to a version that provides RecordError (and absl::string_view signatures) or add a compatibility shim/#if GOOGLE_PROTOBUF_VERSION ... to implement the correct override for both old (AddError(const std::string&, ...)) and new APIs.
This PR updates the function signatures of hash() and AddError() to use string_view and renames AddError to RecordError. In combination with #160 this builds successfully with up-to-date dependencies for me.