Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Protocol Buffers implementation in C

License

NotificationsYou must be signed in to change notification settings

protobuf-c/protobuf-c

Repository files navigation

Build StatusCoverage Status

Overview

This isprotobuf-c, a C implementation of theGoogle Protocol Buffers data serialization format. It includeslibprotobuf-c, a pure C library that implements protobuf encoding and decoding, andprotoc-gen-c, a code generator plugin forprotoc that converts Protocol Buffer.proto files to C descriptor code.protobuf-c formerly included an RPC implementation; that code has been split out into theprotobuf-c-rpc project.

protobuf-c was originally written by Dave Benson and maintained by him 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,protobuf, andpkg-config to be installed.

./configure && make && make install

If building from a git checkout, theautotools (autoconf,automake,libtool) must also be installed, and the build system must be generated by running theautogen.sh script.

./autogen.sh && ./configure && make && make install

Test

If you want to execute test cases individually, please run the following command after running./configure once:

 make check

Documentation

See theonline Doxygen documentation here orthe Wiki for a detailed reference. The Doxygen documentation can be built from the source tree by running:

make html

Synopsis

Use theprotoc command to generate.pb-c.c and.pb-c.h output files from your.proto input file. The--c_out options instructsprotoc to use the protobuf-c plugin.

protoc --c_out=. example.proto

Include the.pb-c.h file from your C source code.

#include "example.pb-c.h"

Compile your C source code together with the.pb-c.c file. Add the output of the following command to your compile flags.

pkg-config --cflags 'libprotobuf-c >= 1.0.0'

Link against thelibprotobuf-c support library. Add the output of the following command to your link flags.

pkg-config --libs 'libprotobuf-c >= 1.0.0'

If using autotools, thePKG_CHECK_MODULES macro can be used to detect the presence oflibprotobuf-c. Add the following line to yourconfigure.ac file:

PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c >= 1.0.0])

This will place compiler flags in thePROTOBUF_C_CFLAGS variable and linker flags in thePROTOBUF_C_LDFLAGS variable. Readmore information here about thePKG_CHECK_MODULES macro.

Versioning

protobuf-c follows theSemantic Versioning Specification as of version 1.0.0.

Note that as of version of 1.0.0, the header files generated by the protobuf-c compiler contain version guards to prevent incompatibilities due to version skew between the generated.pb-c.h files and the publicprotobuf-c.h include file supplied by thelibprotobuf-c support library. While we will try not to make changes toprotobuf-c that will require triggering the version guard often, such as releasing a new major version ofprotobuf-c, this cannot be guaranteed. Thus, it's a good idea to recompile your.pb-c.c and.pb-c.h files from their source.proto files withprotoc as part of your build system, with proper source file dependency tracking, rather than shipping potentially stale.pb-c.c and.pb-c.h files that may not be compatible with thelibprotobuf-c headers installed on the system in project artifacts like repositories and release tarballs. (Note that the output of the protobuf-c code generator is not standalone, as the output of some other tools that generate C code is, such asflex andbison.)

Major API/ABI changes may occur between major version releases, by definition. It is not recommended to export the symbols in the code generated by the protobuf-c compiler in a stable library interface, as this will embed theprotobuf-c ABI into your library's ABI. Nor is it recommended to install generated.pb-c.h files into a public header file include path as part of a library API, as this will tie clients of your library's API to particular versions oflibprotobuf-c.

Mailing list

protobuf-c's mailing list is hosted on aGoogle Groups forum. Subscribe by sending an email toprotobuf-c+subscribe@googlegroups.com.

Contributing

The most recently releasedprotobuf-c version is kept on themaster branch, while thenext branch is used for commits targeted at the next release. Please base patches and pull requests against thenext branch, not themaster branch.

Copyright to all contributions are retained by the original author, but must be licensed under the terms of theBSD-2-Clause license. Please add aSigned-off-by header to your commit message (git commit -s) to indicate that you are licensing your contribution under these terms.


[8]ページ先頭

©2009-2025 Movatter.jp