【发布时间】:2021-01-27 17:15:36
【问题描述】:
我使用 protoc 生成了这个 proto 文件。 protoc -I=C:\proto --cpp_out=C:\proto C:\proto\test.proto
syntax = "proto3";
option java_package = "ex.grpc";
package mathtest;
// Defines the service
service MathTest {
// Function invoked to send the request
rpc sendRequest (MathRequest) returns (MathReply) {}
}
// The request message containing requested numbers
message MathRequest {
int32 a = 1;
int32 b = 2;
}
// The response message containing response
message MathReply {
int32 result = 1;
}
生成这个函数的头文件:
virtual void sendRequest(::PROTOBUF_NAMESPACE_ID::RpcController* controller,
const ::mathtest::MathRequest* request,
::mathtest::MathReply* response,
::google::protobuf::Closure* done);
当我基于的示例像这样覆盖此函数时:
/Status sendRequest(
ServerContext* context,
const MathRequest* request,
MathReply* reply
) override {
我做错了什么以及我应该如何生成 proto 文件?
【问题讨论】:
标签: c++ grpc protobuf-c