I have a this sample protobuf message:
message testMessage{
oneof oneOfTest{
string test2 = 2;
int32 test3 = 3;
}
}
But it is failing to compile, saying:
[ERROR] protoc failed error: Expected "required", "optional", or "repeated".
test.proto: Missing field number.
Based on the line numbers, it is looking for that required/optional/repeated keyworkd before "oneof" and it is complaining of the missing field number after "oneOfTest". Is this not the correct way to use oneof? I am using the java compiler for Protobuf.
Protocol Buffer (Protobuf) provides two simpler options for dealing with values that might be of more than one type. The Any type can represent any known Protobuf message type. And you can use the oneof keyword to specify that only one of a range of fields can be set in any message.
Adding Comments To add comments to your .proto files, use C/C++-style // and /* ... */ syntax.
Protobuf doesn't support inheritance. Having a common header and using composition is the best solution. You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
Make sure you're using the most recent version of the protocol buffer compiler: oneof
syntax was added in only the very most recent version, released last Monday.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With