protocol buffers - How to include .proto files having mutual dependency -
i have 2 .proto files, has 2 packages have mutual dependency.
a.proto
syntax = "proto3"; import "b.proto"; package a; message cert { string filename = 1; uint32 length = 2; } enum state { = 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 try generate cpp files, following error seen
# protoc -i. --cpp_out=. b.proto b.proto: file recursively imports itself: b.proto -> a.proto -> b.proto
how can achieved ?
note : protoc version used libprotoc 3.3.0
proto compiler won't let include circular dependencies. have organize code such there aren't recursive imports. 1 organization of sample code above be:
a.proto
syntax = "proto3"; package a; message cert { string filename = 1; uint32 length = 2; } enum state { undefined = 0; = 1; down = 2; } b.proto
syntax = "proto3"; import "a.proto"; package b; message event { a.cert certificate = 1; a.state curstate = 2; } message events { repeated event curevent = 1; uint32 val = 2; } your events type doesn't use a.proto, , uses event type b.proto. makes sense move b.proto.
Comments
Post a Comment