Using enum as extension id?

19 views
Skip to first unread message

crotty.ch...@gmail.com

unread,
May 7, 2013, 4:31:33 PM5/7/13
to prot...@googlegroups.com
Is it possible to define an extension and use an enum value as the extension id?

Say with the following files defined:

file: MessageType.proto:

enum MessageType {
    MSG_TYPE_1 = 100;
    MSG_TYPE_2 = 101;
}


file: AMessage.proto:

import "MessageType.proto";

message AMessage {
    required MessageType  type = 1;
    extensions 100 to 200;
}


file: MessageType1.proto:

import "MessageType.proto";
import "AMessage.proto";

message MessageType1 {
  extend AMessage {
    required MessageType1  ext_type = 100;  // here I would like to use MessageType.MSG_TYPE_1
  }
}


Is it possible to use an enum definition in the extension definition?  I keep getting an error from protoc saying it is expecting a field number.

Thanks,
Chris
Reply all
Reply to author
Forward
0 new messages