I'm trying to define my custom field option in google protocol buffers. If I create such a file, everything works ok:
import "google/protobuf/descriptor.proto";
package tutorial;
extend google.protobuf.FieldOptions {
optional int32 myopt = 70000;
}
message Persona {
required string name = 1 [(myopt)=5];
}
However, if I try to move "myopt" definition to another file, compilation fails:
myext.proto:
package myext;
import "google/protobuf/descriptor.proto";
extend google.protobuf.FieldOptions {
optional int32 myopt = 70000;
}
addressbook.proto:
import "google/protobuf/descriptor.proto";
import "myext.proto";
package tutorial;
message Persona {
required string name = 1 [(myopt)=5];
}
compilation:
$ protoc --cpp_out=. -I/usr/include -I. addressbook.proto
addressbook.proto:8:29: Option "(myopt)" unknown.
Is there any way to define custom field options in other file than the one that use it? It is important to move common part to a common file if I want to use my option in several .proto files.