Google-protobuf: How to create unions using Google protocol buffer

Viewed 18220

I am currently trying to use Google Protocol Buffers for C language. I am a little unsure as to how to create a C union using GPB.

For example, with a proto file as follows:

message msgToSend
{
 required Type msg_type=1; //Type is a predefined enum to determine message type
 optional ReqMsg1 msg1=2;
 optional ReqMsg2 msg2=3;
}

I expect above to generate a union upon compilation but a structure is generated as follows:

struct _msgToSend
{
 ProtobufCMessage base;
 Type msg_type;
 ReqMsg1 msg1;
 ReqMsg2 msg2;
}
2 Answers
Related