The compiler doesn't support that syntax (DataType = DataOther | DataTest).
Maybe a oneof field is what you are looking for; that would look something
like this:

message DataType {
  oneof data_type {
    DataOther data_other = 1;
    DataTest data_test = 2;
  }
}

On Mon, Mar 20, 2017 at 10:08 AM, Leonardo Toledo <lmftol...@gmail.com>
wrote:

> Hi! I am writing my "file.proto" and when i write a constant the compiler
> give an error called "Expected top-level statement (e.g. "message")" and i
> do not know why! In my "file.proto" i have the follow:
>
> "message Test{
> string str1 = 1;
> DataType data = 2;
> }
>
> DataType = DataOther | DataTest;"
>
> This piece above of code is a part of what i have in my "file.proto" and i
> want define the variable "Datatype" as a constant that can be of 2
> different types, being them, DataOther or DataTest. But when i am
> compiling, the compiler give me the error that i mencioned. Can anyone help
> me please, because i do not know how solve this problem!?
>
> Thanks in advance and i am waiting for some answer,
> Leonardo Toledo
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to