No description
  • C 71.2%
  • Python 23.3%
  • CMake 3.1%
  • Shell 1.3%
  • PureBasic 0.3%
  • Other 0.6%
Find a file
Nick Cooke 3851d94a41
Merge pull request #2 from firebase/nc.xcode26.spm
fix: add explicit platform versions to Package.swift
2026-06-09 12:28:04 -04:00
.github/workflows Update Python2 CI workflow to Ubuntu 20.04 2024-02-17 15:09:28 +02:00
docs Fix undefined behavior with bool fields (#434) 2019-10-02 10:56:49 +03:00
examples network_server example: Detect count=0 in read_callback() (#421) 2019-08-27 14:47:14 +03:00
extra Publishing nanopb-0.3.9.10 2024-02-16 11:02:38 +02:00
generator Publishing nanopb-0.3.9.10 2024-02-16 11:02:38 +02:00
spm-test More seamless SwiftPM implementation (#567) 2020-08-07 12:38:52 +03:00
spm_headers More seamless SwiftPM implementation (#567) 2020-08-07 12:38:52 +03:00
spm_resources [nanopb] Add Apple privacy manifest 2024-02-16 10:56:43 +02:00
tests Add testcase for #647: invalid free with oneof 2021-03-20 09:55:28 +02:00
tools Backported Python pip packaging rules. 2019-12-13 22:12:52 +02:00
.gitignore .gitignore: don't ignore generator-bin files (#419) 2019-08-27 14:47:31 +03:00
.travis.yml Add scons package to travis rules, for build automation 2019-08-27 14:46:59 +03:00
AUTHORS.txt Publishing nanopb-0.3.9.6 2020-06-23 10:30:00 +03:00
BUILD Bazel: export LICENSE.txt file. 2016-08-10 01:27:20 -07:00
CHANGELOG.txt Publishing nanopb-0.3.9.10 2024-02-16 11:02:38 +02:00
CMakeLists.txt Publishing nanopb-0.3.9.10 2024-02-16 11:02:38 +02:00
CONTRIBUTING.md Add contributing.md to provide issue templates on github 2015-10-24 22:20:53 +03:00
library.json Publishing nanopb-0.3.9.10 2024-02-16 11:02:38 +02:00
LICENSE.txt Moving files around 2013-12-29 20:26:57 +02:00
Package.swift fix: add explicit platform versions to Package.swift 2026-06-09 10:40:40 -04:00
pb.h Publishing nanopb-0.3.9.10 2024-02-16 11:02:38 +02:00
pb_common.c Fix clang undefined behavior sanitizer errors. 2022-04-22 21:46:07 +03:00
pb_common.h Rename poorly named identifier to avoid name conflicts. 2014-08-18 21:11:10 +03:00
pb_decode.c Fix clang undefined behavior sanitizer errors. 2022-04-22 21:46:07 +03:00
pb_decode.h Fix undefined behavior with bool fields (#434) 2019-10-02 10:56:49 +03:00
pb_encode.c Fix clang undefined behavior sanitizer errors. 2022-04-22 21:46:07 +03:00
pb_encode.h docs: fix simple typo, specifing -> specifying (#614) 2020-11-25 12:59:12 +02:00
README.md Update README.md 2018-10-17 13:34:54 -07:00
WORKSPACE bazel: Add WORKSPACE 2017-07-09 19:28:05 +04:00

Nanopb - Protocol Buffers for Embedded Systems

Build Status

Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.

Using the nanopb library

To use the nanopb library, you need to do two things:

  1. Compile your .proto files for nanopb, using protoc.
  2. Include pb_encode.c, pb_decode.c and pb_common.c in your project.

The easiest way to get started is to study the project in "examples/simple". It contains a Makefile, which should work directly under most Linux systems. However, for any other kind of build system, see the manual steps in README.txt in that folder.

Using the Protocol Buffers compiler (protoc)

The nanopb generator is implemented as a plugin for the Google's own protoc compiler. This has the advantage that there is no need to reimplement the basic parsing of .proto files. However, it does mean that you need the Google's protobuf library in order to run the generator.

If you have downloaded a binary package for nanopb (either Windows, Linux or Mac OS X version), the protoc binary is included in the 'generator-bin' folder. In this case, you are ready to go. Simply run this command:

generator-bin/protoc --nanopb_out=. myprotocol.proto

However, if you are using a git checkout or a plain source distribution, you need to provide your own version of protoc and the Google's protobuf library. On Linux, the necessary packages are protobuf-compiler and python-protobuf. On Windows, you can either build Google's protobuf library from source or use one of the binary distributions of it. In either case, if you use a separate protoc, you need to manually give the path to nanopb generator:

protoc --plugin=protoc-gen-nanopb=nanopb/generator/protoc-gen-nanopb ...

Running the tests

If you want to perform further development of the nanopb core, or to verify its functionality using your compiler and platform, you'll want to run the test suite. The build rules for the test suite are implemented using Scons, so you need to have that installed (ex: sudo apt install scons on Ubuntu). To run the tests:

cd tests
scons

This will show the progress of various test cases. If the output does not end in an error, the test cases were successful.

Note: Mac OS X by default aliases 'clang' as 'gcc', while not actually supporting the same command line options as gcc does. To run tests on Mac OS X, use: "scons CC=clang CXX=clang". Same way can be used to run tests with different compilers on any platform.