c++ - How can optional fields that are not assigned values in protocbuf be allocated spaces -


if defined:

message {  required int32 first = 1;  optional int32 second = 2; } 

the size of space when set_second(0) serializetoarray() not same when set_second(14353355445) serializetoarray()

are there ways make them have same size of space ?

in other ways,how can make optional fields not assigned values have same size of space assigned values?

my recommendation is: don't try protobuf. protobuf not designed give fixed nor predictable sizes, if that's want, protobuf isn't right tool job.

sure, can use hacks using fixed32 , trying make sure fields have non-default values, fighting tools. else change in future makes sizes unpredictable again. better choose tool matches needs.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -