To give the same answer as Alek with slightly different wording: The accessors for extensions are analogous to the accessors for a normal field. For a normal message-type field, there is no "set" accessor. There is only "mutable". For example:
// Proto message Foo { optional Bar bar = 1; } message Bar { optional int32 i = 1; } // C++ Foo foo; foo.mutable_bar()->set_i(1); So with extensions, you should not use SetExtension() for embedded messages. You should use MutableExtension(): f.MutableExtension(Bar::ck)->set_offset(100); On Thu, Jan 8, 2009 at 11:32 PM, chongyc <chongy...@gmail.com> wrote: > > I defined proto by following . > > message Ch { > required int32 offset = 1; > } > > message Foo { > required string cmd = 1; > > extensions 1000 to max; > } > > message Bar { > extend Foo { > required Ch ck = 1000; > } > } > > Then I generated c++ code from it. > It's OK > > I am going to set value to extension ck() > I compiled c++ source following below. > > term2relay::Foo f; > term2relay::Bar b; > term2relay::Ch c; > > c.set_offset (100); > > f.SetExtension(Bar::ck, c); > > But compiling failed in source code line > f.SetExtension(Bar::ck, c); > > How to do it ? > > Please help me. > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---