Search code examples
protocol-buffersprotoc

Google protocol buffers - Binary compatibility between protoc-c and protoc


I have C code written in proto2 format and compiled by the protoc-c compiler. What I would like to know is whether that code is binary compatible with serialization/de-serialization code generated by the 'protoc' compiler (that also happens to understand version 3 of protobuf)? For some reason I am not able to get a definitive answer to this question. The reason I am wondering is because there are already backwards compatibility issues between version 3 and version 2, so I am a little uncertain with the protoc-c and protoc toolkits and how they handle versions.

Thanks!


Solution

  • Yes, these two implementations should be compatible--you can serialize messages with one implementation and successfully parse them with another. I have not personally tried protobuf-c but based on its description it is just another implementation of the same protocol buffer wire format.

    You mentioned differences between syntax = "proto2" and syntax = "proto3". It is true that these are different and you would have to be careful if you want to migrate from one to the other, but I think this issue is orthogonal to your question about compatibility between protobuf-c and Google's protobuf implementation.