Can I memcpy protobuf C++ objects if they only contain fixed length fields?

406 views
Skip to first unread message

Yan Yan

unread,
May 14, 2016, 11:13:31 AM5/14/16
to Protocol Buffers
No strings, no int64, no int32, no repeated fields.
Only sfixed64, sfixed32, nested messages.
Are there any dynamic allocation? Are there any pointers? Is there a subset of protobuf datatypes that I can use to make fixed size objects that works on memcpy? Will the sizeof() operator work? Ideally they should work like C structs of fixed size, and they come with a higher level API. The wire format is good for cross-language compatibility. Thx.

Feng Xiao

unread,
May 14, 2016, 7:25:07 PM5/14/16
to Yan Yan, Protocol Buffers
On Sat, May 14, 2016 at 8:13 AM, Yan Yan <lamh...@gmail.com> wrote:
No strings, no int64, no int32, no repeated fields.
Only sfixed64, sfixed32, nested messages.
Are there any dynamic allocation?
Yes.
 
Are there any pointers?
Yes.
 
Is there a subset of protobuf datatypes that I can use to make fixed size objects that works on memcpy?
No. Even a complete empty protobut message cannot be memcpy.
 
Will the sizeof() operator work? Ideally they should work like C structs of fixed size, and they come with a higher level API. The wire format is good for cross-language compatibility. Thx.
Protobuf C++ objects are not POD and you can't memcpy it.
 

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

Yan Yan

unread,
May 14, 2016, 10:46:59 PM5/14/16
to Protocol Buffers, lamh...@gmail.com
ty
Reply all
Reply to author
Forward
0 new messages