cloudwu/pbc
FreeA protocol buffers library for C
FreeFree tier
About cloudwu/pbc
PBC (Protocol Buffers in C) is a lightweight open-source library for Google Protocol Buffers that operates without code generation. It provides a message API (rmessage/wmessage) for encoding and decoding, and a pattern API that allows direct access to data in native C structs for improved performance. The library supports Lua bindings (Lua 5.1, 5.2, 5.3) and extensions via a prefix naming scheme. It is archived and read-only, with an MIT license.
Key Features
No code generation required
Message API (rmessage for decoding, wmessage for encoding)
Pattern API for high-performance access via native C structs
Lua bindings (Lua 5.1/5.2 and 5.3)
Extension support via prefix naming
Supports enum as both string and integer in message API
MIT license
Buildable with vcpkg, Visual Studio, and Make
Pros & Cons
Pros
- No code generation step simplifies the build process
- Pattern API offers faster serialization and lower memory usage by working directly with C structs
- Lua bindings provide easy integration with scripting
- Permissive MIT license allows use in commercial projects
- Lightweight C library with minimal dependencies
Cons
- Repository is archived and no longer maintained (read-only since Nov 2022)
- Service (RPC) feature is not supported
- No official releases are published on GitHub
- Documentation is limited; design details only available in Chinese blog
- May not be compatible with newer Protocol Buffers versions due to lack of updates
Best For
Serializing and deserializing structured data in C programs without code generationEmbedded systems and constrained environments where protoc code generation is not feasibleIntegrating Protocol Buffers with Lua for configuration or scriptingInter-process communication or network protocols requiring a compact binary format
FAQ
Does PBC require code generation?
No, PBC is designed to work without code generation. It reads .proto files at runtime and provides APIs to access message fields directly.
Does PBC support Lua?
Yes, PBC includes Lua bindings for Lua 5.1, 5.2, and 5.3 located in the binding/lua and binding/lua53 directories.
Is PBC still actively maintained?
The repository was archived by the owner on November 28, 2022, and is now read-only. It is no longer actively maintained.
What APIs does PBC provide?
PBC provides a message API (pbc_rmessage for decoding, pbc_wmessage for encoding) and a pattern API (pbc_pattern) that allows accessing data directly in native C structs for better performance.