Yes, this is the expected behavior. Unset optional fields are not
serialized, so the total size of the serialized message is zero. You can
parse back an empty array of bytes to get an instance of SomeMessage with
an unset `result` field.


On Fri, Apr 17, 2020 at 2:54 PM Евгений Х <[email protected]> wrote:

> Hello!
> I have the protobuf message like this:
>
> *message SomeMessage {*
>
> *    optional uint32 result = 1;*
> *}*
>
> When I don't fill the *result* field and then call the *ByteSize*
> function it returns 0.
>
> Is it correct?
>
> P.S. C++ program
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/77dc856a-9814-417c-82fa-e922a7c48107%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/77dc856a-9814-417c-82fa-e922a7c48107%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
-Nadav

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CANZcNEpkw385SojEjbJ9gmCgAO9B6%3DJLwEojjyH%3D561kGHwjjw%40mail.gmail.com.

Reply via email to