On Jul 5, 2010, at 7:25 , Srivats P wrote:
when a message is serialized its known fields should be written
sequentially by field number, as in the provided C++, Java, and Python
serialization code

Like the encoded wire format, is the above guaranteed for the C++
Serialization API (assuming no unknown fields)?

The "official" protobuf C++, Java, and Python implementations all write the fields out in tag number order (lowest to highest). However, their parsers handle messages where the fields are out of order.

I'm designing a file format based on protobuf. I plan to have the
first field as a fixed size file type magic value and second field as
a fixed size checksum value, followed by other fields. While opening
such a file, I'd like to match the magic value and verify the
checksum, before parsing the whole file.

From this description, it doesn't sound like the field order matters? Serialize the protocol buffer, compute the checksum, then write out the (magic bytes)(checksum)(protocol buffer bytes)?


Evan Jones

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

Reply via email to