【问题标题】:Protocol Buffer - c协议缓冲区 - c
【发布时间】:2021-12-19 07:38:15
【问题描述】:
`stuct` apple
{

    int a;
    char c;

};
struct b
{
int count;
`stuct` apple a[10];
};

如何将这些结构实现到protobuff C 中的消息字段。 我正在寻找一种替代方法来编写 struct apple a[10],而不是在 protobuff 上写 10 次。 你能帮助我吗? 谢谢!

【问题讨论】:

    标签: c struct protocol-buffers grpc


    【解决方案1】:

    我终于明白了。

    message b
    {
      message apple
      {
        int32 a;
        string c;
      }
      int32 count;
      repeated apple a;
    }
    

    这是原型消息。 使用动态数组的向量实现来使用它。它将有助于创建一个结构的N个对象。

    【讨论】: