dave's original style drives me crazy. reformat the C code in protobuf-c/ with "indent -kr -i8" and manually reflow for readability. try to fit most lines in 80 columns, but due to the lengthy type and function names in protobuf-c, enforcing an 80 column rule would result in a lot of cramped statements, so try to fit lines in up to 100 columns if it would improve readability. (e.g., one <=100 column line is probably better than 3-4 <=80 column lines.) ultimately i'd like to adopt most of the recommendations in the linux coding style: https://www.kernel.org/doc/Documentation/CodingStyle. this commit gets us most of the kernel indentation and comment coding style recommendations. later commits will tackle style recommendations that require more intrusive changes: breaking up large functions, replacing macros that affect control flow (e.g., DO_ALLOC). this will hopefully facilitate review and make the code base easier to maintain. i ran the old and new versions of protobuf-c.c through something like: gcc -S -D__PRETTY_FUNCTION__=0 -D__FILE__=0 -D__LINE__=0 -Wall -O0 \ -o protobuf-c.S -c protobuf-c.c and reviewed the diffs of the assembly output to spot any functions that changed, and went back to make sure that any differences were functionally equivalent.
Overview
This is protobuf-c
, a C implementation of Google Protocol Buffers. 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, based on the original protoc
. protobuf-c
formerly included an RPC implementation; that code has been split out into the protobuf-c-rpc project.
protobuf-c
was originally maintained by Dave Benson through version 0.15 but is now being maintained by a new team. Thanks, Dave!
Building
protobuf-c
requires a C compiler, a C++ compiler, Google Protocol Buffers, and pkg-config
to be installed.
./configure && make && make install
If building from a git checkout, the autotools
(autoconf
, automake
, libtool
) must also be installed, and the build system must be generated by running the autogen.sh
script.
./autogen.sh && ./configure && make && make install
Synopsis
Include the protobuf-c
header file:
#include <protobuf-c/protobuf-c.h>
Link against the protobuf-c
library.
-lprotobuf-c
libprotobuf-c
includes a pkg-config
file. It is recommended to use the pkg-config
system in order to determine the complete set of compiler and linker flags for building applications that utilize libprotobuf-c
. If using pkg-config
with autoconf
, the PKG_CHECK_MODULES
macro can be used to detect the presence of libprotobuf-c
:
PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c])
This will place compiler flags in the PROTOBUF_C_CFLAGS
variable and linker flags in the PROTOBUF_C_LDFLAGS
variable.
(Note that the protobuf-c
header file used to be installed as google/protobuf-c/protobuf-c.h
in previous versions.)
Contributing
Please send patches to the protobuf-c mailing list or by opening a GitHub pull request.
Copyright to all contributions are retained by the original author, but must be licensed under the terms of the BSD-2-Clause license. Please add a Signed-off-by
header to your commit message (git commit -s
) to indicate that you are licensing your contribution under these terms.