TimothyP
TimothyP

Reputation: 21745

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.

Upvotes: 21

Views: 27692

Answers (4)

SajadBlog
SajadBlog

Reputation: 575

μpb is a small protobuf implementation written in C.

upb generates a C API for creating, parsing, and serializing messages as declared in .proto files. upb is heavily arena-based

Upvotes: 1

Erik Moqvist
Erik Moqvist

Reputation: 191

pbtools is another alternative. It generates fast C source code to encode and decode protobuf messages.

Also, there is a list of more C implementations here: https://github.com/protocolbuffers/protobuf/blob/master/docs/third_party.md

Upvotes: 5

John Ellinwood
John Ellinwood

Reputation: 14521

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.

Upvotes: 20

Stephan Walter
Stephan Walter

Reputation: 341

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.

Upvotes: 18

Related Questions