Hi All,

I'm seeing an incompatibility between a dynamically generated 
google::protobuf::Message (DynamicMessage?) created with a 
google::protobuf::DynamicMessageFactory and a normal 

What I'm running up against ultimately comes down to this: I can't 
dynamic_cast a DynamicMessage to a known derived type of 
google::protobuf::Message.  For example, let's say my proto file has the 
following message:

package my.package;

messsage Foo
  string blah = 1;
  uint32 bleh = 2;

and I successfully create a my::package::Foo with some code along the lines 

const google::protobuf::Descriptor* descriptor = 
"my.package.Foo" );

google::protobuf::Message* message = myDynamicMessageFactory.GetPrototype( 
descriptor )->New();

after populating message successfully with other commands not shown here, I 
try to do something like:

my::package::Foo foo;
foo.CopyFrom( *message );

and I get a segfault in CopyFrom() because ultimately the following doesn't 
work (the pointer pFoo ends up being NULL down inside 

my::package::Foo* pFoo = dynamic_cast< my::package::Foo* >( message );

It appears as though the derived type of message is not actually 
my::package::Foo, but instead google::protobuf::DynamicMessage (or 
something like that), so naturally the dynamic_cast fails.  I was sure to 
observe the output of message->DebugString() and message->GetTypeName() 
which returned all the appropriate information.

Is there any way to get a real my::package::Foo object from a dynamic one?

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To view this discussion on the web visit 
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to