c++ - Proto 文件对其他 proto 文件的依赖

标签 c++ protocol-buffers

专家:

我有两个 .proto 文件(如下所示),第二个依赖于第一个。

ImageMes​​sage.proto:

package dvr;

message ImageMessage {
    required int32 width = 1;
    required int32 height = 2;
    required int32 type = 3;
    repeated bytes data = 4;
}

DvrMessage.Proto:

package dvr;

import "ImageMessage.proto";

message DvrMessage {
    required ImageMessage firstImage = 1;
    required ImageMessage secondImage = 2;
}

当我尝试按此处所示编译它们时:

protoc --cpp_out=TestProtoc/generated dvrMessage.proto

我收到以下错误:

dvrMessage.proto:6:14: "ImageMessage" is not defined.
dvrMessage.proto:7:14: "ImageMessage" is not defined.

我正在导入它。我还需要做什么?

最佳答案

我就知道!!!在我发布问题的那一刻,答案就来了。我在 this SO question 中找到了提示.果然,我查看了所有 .proto 文件,发现 ImageMes​​sage.proto 文件的包定义中有错字。

我希望这对其他人有帮助。谢谢。

关于c++ - Proto 文件对其他 proto 文件的依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23143959/

相关文章:

c++ - 如何访问这个自动变量?

c++ - 当我将 T& 和 T 作为具有相同名称的函数的返回类型时,如何使用 T& 调用函数

python - 获取 protobuf 消息的父消息(在 python 中)

c# - protobuf-net从.proto文件到.cs文件时是否支持字典? (通过 protogen.exe)

protocol-buffers - gRPC 和模式演化保证?

protocol-buffers - 未找到 Protobuf 时间戳

c++ - 在 OpenGL 中重新组织图像/图片数组以适应 2 次方纹理大小

c++ - 为什么调用 std::vector::back() 会使我的程序崩溃

c++ - 如何在 C++ 中限制日志大小?

docker - Google Cloud ESP 向 gRPC 服务器通告无效的压缩格式