Yes and no....

The wire type encodings are all varint - so yes it is wire compatible.

"Since enum values use varint encoding on the wire" -http://
code.google.com/apis/protocolbuffers/docs/proto.html#enum

However protobuf treats enums a little differently at runtime...

an integer value (int32, etc) is valid as long as it is in range...
while an enum literal is considered an "Unknown Field" if it does not
resolve to a known enum literal.

That is to say that an application expecting the enum will fail to
recognize that the field is even set (unless you're using protocol
buffers 'reflection' and look for it manually) if the value is not one
of the enum literals.

Going enum -> int32 = no loss of data
Going int32 -> enum = possible missing fields (all used values must
have a literal associated with them)


On Sep 30, 11:17 am, Josh Kelley <josh...@gmail.com> wrote:
> Are enums compatible with ints?  For example, can I serialize an int now and
> change it to an enum later without losing the ability to parse old
> messages?  
> Underhttp://code.google.com/apis/protocolbuffers/docs/proto.html#updating, it
> explains that int32, int64, uint32, uint64, and bool are all interchangeable
> when updating message types, but there's no description of enumerations.  
> (The text under enumerations makes it sound like they're compatible, but I'd
> like to verify.)
>
> --
> Josh Kelley

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to