Reputation: 1212
// api_internal.proto
service InvoiceTemplateMatcher {
rpc Process(InvoiceFilePath) returns (UploadStatus) {}
}
message InvoiceFilePath {
string invoice_id = 1;
string file_path = 2;
}
// template_matcher/src/main.cc
class OrkaEngineInvoiceTemplateMatcherImpl final : public InvoiceTemplateMatcher::Service {
private:
Status Process(
ServerContext* context,
orka_engine_internal::InvoiceFilePath* invoicefp,
orka_engine_internal::UploadStatus* response) override {
// do stuff
}
};
Class InvoiceTemplateMatcher::Service
is generated during compile time from that .proto
file.
When I try to compile, I get an error
‘grpc::Status OrkaEngineInvoiceTemplateMatcherImpl::Process(grpc::ServerContext*, orka_engine_internal::InvoiceFilePath*, orka_engine_internal::UploadStatus*)’ marked ‘override’, but does not override
Status Process(ServerContext* context, orka_engine_internal::InvoiceFilePath* invoicefp, orka_engine_internal::UploadStatus* response) override {
As far as I can tell, my code is written in the same way as in Route Guide example. What am I missing?
Upvotes: 15
Views: 66725
Reputation: 979
I know that this post is quite old but I will give a correct answer for any future troubleshoots that person might across while wokring with protobufs.
You are correct saying that the class implementation has been generated automatically and protobuf c++ generation has this class function by default:
virtual ::grpc::Status Process(::grpc::ServerContext* context, const ::orka_engine_internal::InvoiceFilePath* request, ::orka_engine_internal::UploadStatus* response);
So you need to match your function exactly to virtual function. In your example, just change invoicefp
to request
Upvotes: 5
Reputation: 26800
Such an error is issued by the compiler when the the function is not marked virtual
in the base class.
Consider the following minimal example:
class Base{
void Foo() {}
};
class Derived : Base{
void Foo() override {}
};
Compiler issues the error:
error: 'void Derived::Foo()' marked 'override', but does not override
void Foo() override {}
See Demo
The override
specifier specifies that a virtual
function overrides another virtual
function.
Upvotes: 17