// 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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With