Reputation: 53
We are attempting to build a shared library in C++ that can be used in our apps on Android and iOS. The library uses protobuf generated C++ classes in order to convert between C++ objects and Java/Swift objects on Android/iOS. The C++ code compiles just fine for Android, but the Xcode compiler is throwing multiple errors exclusively in our protobuf generated C++ classes. This code compiles on Windows, MacOS and Linux as well.
I've tried changing the C++ language version to GNU++ (we are using C++17) and attempted to change some compiler settings in Xcode, but the same errors keep showing up. I've also tried to look into changing how protoc generates the C++ files, but I haven't found anything.
So far I'm only having errors in a protobuf generated C++ header file:
void SerializeWithCachedSizes(
::PROTOBUF_NAMESPACE_ID::io::CodedOutputStream* output) const final;
::PROTOBUF_NAMESPACE_ID::uint8* InternalSerializeWithCachedSizesToArray(
::PROTOBUF_NAMESPACE_ID::uint8* target) const final;
On the first line the error is "Only virtual member functions can be marked 'final'", and the third line has the error "Non-virtual member function marked 'final' hides virtual member function".
This code is repeated multiple times throughout our protobuf generated class, so we're seeing the same two errors over and over again.
I could simply edit the code but I would like to avoid messing with auto-generated code if possible.
Upvotes: 3
Views: 1246
Reputation: 333
I had the same problem with Linux. In my case it was some environment variables (specifically and active conda virtual env) which triggered generation of "SerializeWithCachedSizes". Without the conda environment variables the "SerializeWithCachedSizes" did not appear in the code and didn't cause the compile error. Conda uses its own protoc installation (which had the same version number as the one installed from source via apt).
Upvotes: 1