Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a good C implementation of Google Protocol Buffers

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.

like image 849
TimothyP Avatar asked Sep 08 '10 19:09

TimothyP


People also ask

Are protocol buffers still used?

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.

Does Google use protobuf?

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.

What is protobuf C?

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.

Is protobuf more efficient than JSON?

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.


2 Answers

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 called protoc-c.

like image 196
John Ellinwood Avatar answered Oct 25 '22 03:10

John Ellinwood


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.

like image 45
Stephan Walter Avatar answered Oct 25 '22 05:10

Stephan Walter