Commit 1678f1fb authored by Robert Edmonds's avatar Robert Edmonds

protoc-gen-c/compat.h: Add `compat::StringView` type

protobuf >= 30.x replaces `const std::string&` in various APIs with
its own string view type that may actually be a `absl::string_view`.
Introduce our own `compat::StringView` type that we can use instead
of `const std::string&` in order to support compiling across multiple
protobuf versions.
parent b28683f8
......@@ -28,6 +28,8 @@
#ifndef PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
#define PROTOBUF_C_PROTOC_GEN_C_COMPAT_H__
#include <string>
#if GOOGLE_PROTOBUF_VERSION >= 4022000
# define GOOGLE_ARRAYSIZE ABSL_ARRAYSIZE
# define GOOGLE_CHECK_EQ ABSL_CHECK_EQ
......@@ -39,6 +41,12 @@ namespace protobuf_c {
namespace compat {
#if GOOGLE_PROTOBUF_VERSION >= 6030000
typedef google::protobuf::internal::DescriptorStringView StringView;
#else
typedef const std::string& StringView;
#endif
} // namespace compat
} // namespace protobuf_c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment