I ran into a situation today in which I needed to use the "reserved" keyword in a protobuf definition, so that in the future, nobody would use those fields. I've attached a screenshot of what the docs say, from https://developers.google.com/protocol-buffers/docs/proto#reservedHowever, when I try to use that keyword in an actual message with field definitions, protoc always complains with the following error:Expected "required", "optional", or "repeated".My protobuf definition looks like this:message MyMessage {// Some commentsreserved, 4, 108, 109;
I just realized, there's a typo in my example. It should say:reserved 4, 108, 109;Note there's no comma after the reserved keyword.Also, I checked, and the protoc compiler I'm using reports itself as: libprotoc 2.5.0
On Wed, May 25, 2016 at 3:44 PM, Marcos Juarez <mju...@gmail.com> wrote:I ran into a situation today in which I needed to use the "reserved" keyword in a protobuf definition, so that in the future, nobody would use those fields. I've attached a screenshot of what the docs say, from https://developers.google.com/protocol-buffers/docs/proto#reservedHowever, when I try to use that keyword in an actual message with field definitions, protoc always complains with the following error:Expected "required", "optional", or "repeated".My protobuf definition looks like this:message MyMessage {// Some commentsreserved, 4, 108, 109;// Some more commentsrequired string event_uuid = 1 ;required string date = 2 ;required string timezone = 3 ;optional string field1 = 101 ;optional string field2 = 110 ;}Am I reading that spec wrong, or is the reserved keyword broken?Marcos
--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To post to this group, send email to prot...@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
Thanks Feng.It does look like the documentation is wrong then. I checked, and the "Reserved" section shows up when looking at the Language Guide for both proto2 and proto3.