Google officially provides a C++ implementation of Google Protocol buffers, but I'm looking for a C implementation.
I will not be using it myself, but my hope is that I can use this tool to generate C code for our Google Protocol Buffer definitions which I can then hand of to the C developers.
I'm not looking for any RPC functionality, simply encoding and decoding of Google Protocol Buffer messages.
The design goals for Protocol Buffers emphasized simplicity and performance. In particular, it was designed to be smaller and faster than XML. Protocol Buffers are widely used at Google for storing and interchanging all kinds of structured information.
Protocol buffers, or Protobuf, is a binary format created by Google to serialize data between different services. Google made this protocol open source and now it provides support, out of the box, to the most common languages, like JavaScript, Java, C#, Ruby and others.
This is protobuf-c, a C implementation of the Google Protocol Buffers data serialization format. It includes libprotobuf-c , a pure C library that implements protobuf encoding and decoding, and protoc-c , a code generator that converts Protocol Buffer . proto files to C descriptor code.
JSON is usually easier to debug (the serialized format is human-readable) and easier to work with (no need to define message types, compile them, install additional libraries, etc.). Protobuf, on the other hand, usually compresses data better and has built-in protocol documentation via the schema.
Use protobuf-c (now at Github as protobuf-c).
From their official site:
This package provides a code generator and runtime libraries to use Protocol Buffers from pure C (not C++).
It uses a modified version of
protoc
calledprotoc-c
.
There's also Nanopb which is more light-weight.
For example, it does not store message and field names in the code, so introspection (searching a field by name) is not possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With