How to include .proto files having mutual dependency

Viewed 7143

I have two .proto files, which has two packages that have mutual dependency.

a.proto

syntax = "proto3";
import "b.proto";

package a;

message cert {
    string filename = 1;
    uint32 length = 2;
}

enum state {
    UP = 1;
    DOWN = 2;
}

message events {
    repeated b.event curevent = 1;
    uint32 val = 2;
}

b.proto

syntax = "proto3";
import "a.proto";

package b;

message event {
     a.cert certificate = 1;
     a.state curstate = 2;
}

When I try to generate cpp files, following error is seen

# protoc -I. --cpp_out=. b.proto b.proto: File recursively imports itself: b.proto -> a.proto -> b.proto

How can this be achieved ?

Note : protoc version used is libprotoc 3.3.0

1 Answers
Related