1# Nanopb: Migration from older versions
2
3This document details all the breaking changes that have been made to
4nanopb since its initial release. For each change, the rationale and
5required modifications of user applications are explained. Also any
6error indications are included, in order to make it easier to find this
7document.
8
9Nanopb-1.0.0 (2025-xx-xx)
10-------------------------
11
12### Remove Python 2 support
13
14**Rationale:** Python 2 interpreter was deprecated in 2020. For backward
15compatibility, nanopb has retained support for running the generator with
16Python 2 for the 0.4.x series. That has required several tricks that
17complicate the codebase.
18
19**Changes:** Removed Python 2 support files and code hacks needed to
20make it work.
21
22**Required actions:** Upgrade to Python 3 and ensure `python-protobuf`
23is installed.
24
25Nanopb-0.4.9 (2024-09-19)
26-------------------------
27
28### CMake rules now default to grpcio_tools protoc
29
30**Rationale:** Previously CMake rules primarily looked for `protoc` in system
31path. This was often an outdated version installed from package manager, and
32not necessarily compatible with `python-protobuf` version installed from `pip`.
33
34**Changes:** CMake rules now default to using `generator/protoc`, which in
35turn uses `grpc_tools` Python package if available. If it is not available,
36system path is searched for `protoc`.
37
38**Required actions:** For most users, no actions are needed. In case of
39version incompatibilities, `pip install --user --upgrade grpcio-tools protobuf`
40is recommended. If needed, `PROTOBUF_PROTOC_EXECUTABLE` can be set to override
41the default.
42
43**Error indications:** `Failed to import generator/proto/nanopb_pb2.py` if
44versions of `protoc` selected by CMake is different than installed `python-protobuf`.
45
46### Use uint8_t for pb_byte_t when UINT8_MAX is defined
47
48**Rationale:** Previously `pb_byte_t` was always defined as `uint8_least_t`.
49This could be annoying on some platforms without this define, or when some
50compiles might warn on conversion from `uint8_t`. However not all platforms
51support `uint8_t` sized access.
52
53**Changes:** The `stdint.h` header will define `UINT8_MAX` exactly if `uint8_t`
54is available. Use it to select which type to typedef.
55
56**Required actions:** Usually none. If any compiler warnings are generated,
57they can either be fixed or `PB_BYTE_T_OVERRIDE` can be defined to `uint_least8_t`
58to restore old behavior.
59
60**Error indications:** Implicit conversion from `uint_least8_t` to `uint8_t`.
61
62### Migrate to bzlmod
63
64**Rationale:** Due to the [shortcomings of the WORKSPACE system](https://bazel.build/external/overview#workspace-shortcomings),
65Bzlmod is going to replace the legacy WORKSPACE system in future Bazel releases.
66Therefore, nanopb has been migrated to use bzlmod to better support newer bazel versions.
67
68**Changes**
69* upgrade bazel deps
70  * bazel_skylib: 1.7.1
71  * rules_python: 0.34.0
72  * rules_proto: 6.0.2
73  * protobuf: 24.4
74  * rules_proto_grpc: 5.0.0
75* Start using bzlmod (MODULE.bazel)
76
77**Required actions:** bazel build using WORKSPACE has been deprecated. To use bzlmod, adding below content to your MODULE.bazel
78```py
79bazel_dep(name = "nanopb", version = "0.4.9")
80git_override(
81    module_name = "nanopb",
82    remote = "https://github.com/nanopb/nanopb.git",
83    commit = "<commit>",
84)
85```
86noted that the name of the module has been changed to `nanopb`, to better fit the convention of bzlmod.
87If the old name `com_github_nanopb_nanopb` is preferred, can add `repo_name` parameter to indicate the repo name.
88```py
89bazel_dep(name = "nanopb", version = "0.4.9", repo_name="com_github_nanopb_nanopb")
90```
91
92### Separate enum_intsize setting
93
94**Rationale:** Nanopb-0.4.7 extended `int_size` option to affect enums.
95This is only supported by C++11 and C23 compilers.
96The generation used `#ifdef` to limit size option to use on C++ compilers.
97This caused binary incompatibility when project mixed C and C++ files.
98
99**Changes**: `enum_intsize` is now a separate option, and does not use `#ifdef`.
100If compiler does not support the setting, compilation will fail.
101
102**Required actions:** If using the recently introduced `int_size` option on enums, update to use `enum_intsize` instead.
103
104**Error indications:** Enum integer sizes use defaults as the old setting is ignored.
105
106Nanopb-0.4.8 (2023-11-11)
107-------------------------
108
109### Fix naming conflicts with CMake installation
110
111**Rationale:** Previously `CMakeLists.txt` installed nanopb Python module under name `proto` and include file directly as `/usr/include/pb.h`. These names have potential to conflict with other libraries.
112
113**Changes:** Python module is installed as `nanopb` and include files under `/usr/include/nanopb`.
114
115**Required actions:** Only affects users who install nanopb using the `cmake` build system.
116Does not affect use of `FindNanopb.cmake`.
117Calling nanopb generator should work as before.
118Include path may need adjustment if not using `nanopb-targets.cmake` to determine it.
119
120**Error indications:** Include file `pb.h` not found when compiling against a system-wide installation done with CMake.
121
122Nanopb-0.4.7 (2022-12-11)
123-------------------------
124
125### Add int_size option to enum fields
126
127**This option was separated to `enum_intsize` in nanopb-0.4.9. This migration notice has been updated to match.**
128
129**Rationale:** The `packed_enum` option does not work with MSVC due to `#pragma pack` not supporting enums with MSVC. To workaround this, enum sizes can be specified with the new `int_size` option. Note that this is only supported when generating C++.
130
131**Changes:** The ~~`int_size`~~ `enum_intsize` option can be specified for enums.
132
133**Required actions:** ~~Any users concerned about the size of the generated C++ enums and are setting the int_size of enums via a wildcard (e.g. `MyMessage.*  int_size=IS_8`) will need to instead set the `int_size` option for individual fields.~~
134
135**Error indications:** ~~The size of generated C++ enums has changed.~~
136
137### Updated include path order in FindNanopb.cmake
138
139**Changes:** The include path passed to `protoc` by the CMake rules was updated.
140
141**Required actions:** No changes needed for most users.
142In some specific cases it could change the directory hierarchy generated by `protoc`.
143More details in
144[pull request #822](https://github.com/nanopb/nanopb/pull/822).
145
146**Error indications:** Generated `.pb.c` or `.pb.h` file not found when building
147with CMake rules.
148
149Nanopb-0.4.6 (2022-05-30)
150-------------------------
151
152### NANOPB_VERSION define is now a string
153
154**Changes:** To ease `NANOPB_VERSION` macro usage, the value is directly a string.
155
156**Required actions:** Most nanopb users probably never used that macro. If so,
157you certainly use the `#` preprocessor to convert it as string. You, now,
158only have to call it directly, like this for example:
159`strcpy(myvar, NANOPB_VERSION);`
160
161### FindNanopb.cmake now requires protoc 3.6.0 or newer by default
162
163**Changes:** The default options passing method now uses `--plugin-opt` which
164is supported by protoc 3.6.0 and newer (released in 2018).
165
166**Required actions:** Update `protoc` if needed, or alternatively install
167`grpcio-tools` package from `pip`. If neither is possible, the
168`NANOPB_PROTOC_OLDER_THAN_3_6_0` cmake option can be used to restore the old
169style option passing. Note that it has problems with special characters such
170as `:`.
171
172**Error indications:** "`protoc: Unknown flag: --nanopb_opt`"
173
174### pb.h uses C11 _Static_assert keyword by default
175
176**Rationale:** The nanopb generated headers use static assertions to catch
177errors at compile time. There are several mechanisms to implement this.
178The most widely supported is C11 `_Static_assert` keyword.
179Previously the code used negative size array definition trick, which is
180supported already in C99 but does not work with every compiler and can
181produce confusing error messages.
182
183**Changes:** Now `_Static_assert` is used by default.
184
185**Required actions:** If the keyword is not recognized, set the compiler to
186C11 standard mode if available. If it is not available, define either `PB_C99_STATIC_ASSERT`
187or `PB_NO_STATIC_ASSERT` in `pb.h` or on compiler command line.
188
189**Error indications:** `Undefined identifier _Static_assert`
190
191Nanopb-0.4.4 (2020-11-25)
192-------------------------
193
194### Remove outdated generator/nanopb/options.proto
195
196**Changes:** Back in 2018, it was considered in pull request #241 to
197move nanopb generator options to a separate namespace. For this reason,
198a transitional file was added. It was later abandoned and is now removed
199to avoid confusion.
200
201**Required actions:** Most nanopb users probably never used that transitional
202file at all. If your `.proto` files import it, change to using `generator/proto/nanopb.proto`.
203
204**Error indications:** Errors about missing file `options.proto` when running
205the generator.
206
207Nanopb-0.4.3 (2020-09-21)
208-------------------------
209
210### pb_msgdesc_t struct has new fields
211
212**Changes:** New fields `required_field_count` and
213`largest_tag` were added to `pb_msgdesc_t`
214and existing fields were reordered.
215
216**Required actions:** All `.pb.c` files must be recompiled.
217Regeneration is not needed.
218
219**Error indications:** Messages may fail to encode or decode, or the
220code can crash inside `load_descriptor_values()` in
221`pb_common.c`.
222
223Nanopb-0.4.2 (2020-06-23)
224-------------------------
225
226### Generator now uses Python 3 by default
227
228**Rationale:** Previously `nanopb-generator.py` had hashbang
229of `#!/usr/bin/env python`, which would execute with Python
2302 on most systems. Python 2 is now deprecated and many libraries are
231dropping support for it, which makes installing dependencies difficult.
232While `nanopb_generator.py` has worked with Python 3 for
233years now, and overriding the python version was possible with
234virtualenv, that was an extra complication.
235
236**Changes:** Hashbang now uses `#!/usr/bin/env python3`.
237New file `nanopb_generator.py2` can be used to run with
238Python 2, if necessary.
239
240**Required actions:** If possible, just verify Python 3 is installed and
241necessary dependencies are installed for it. For example `pip3 install protobuf grpcio-tools`
242should take care of it. If this is not possible, call `nanopb_generator.py2` from your build
243scripts instead.
244
245**Error indications:** `python3: command not found` if
246Python 3 is not installed.
247`Could not import the Google protobuf Python libraries` if dependencies are only installed for Python 2.
248
249Nanopb-0.4.0 (2019-12-20)
250-------------------------
251
252### New field descriptor format
253
254**Rationale:** Previously information about struct fields was stored as
255an array of `pb_field_t` structures. This was a
256straightforward method, but required allocating space for e.g.
257submessage type and array size for all fields, even though most fields
258are not submessages nor arrays.
259
260**Changes:** Now field information is encoded more efficiently in
261`uint32_t` array in a variable-length format. Old
262`pb_field_t` structure has been removed and it is now a
263typedef for `pb_field_iter_t`. This retains compatibility
264with most old callback definitions. The field definitions in
265`.pb.h` files are now of type `pb_msgdesc_t`.
266
267**Required actions:** If your own code accesses the low-level field
268information in `pb_field_t`, it must be modified to do so
269only through the functions declared in `pb_common.h`.
270
271**Error indications:** `incompatible pointer type` errors
272relating to `pb_field_t`
273
274### Changes to generator default options
275
276**Rationale:** Previously nanopb_generator added a timestamp header to
277generated files and used only basename of files in
278`#include` directives. This is different than what the
279`protoc` C++ backend does.
280
281**Changes:** Now default options are `--no-timestamp` and
282`--no-strip-path`.
283
284**Required actions:** If old behaviour is desired, add
285`--timestamp` and `--strip-path` options to
286`nanopb_generator.py` or on `protoc` command
287line as `--nanopb_out=--timestamp,--strip-path:outdir`.
288
289**Error indications:** Compiler error: cannot find include file
290`mymessage.pb.h` when compiling
291`mymessage.pb.c`.
292
293### Removal of bundled plugin.proto
294
295**Rationale:** Google's Python protobuf library, which is used in
296nanopb generator, has included `plugin_pb2` with it since
297version 3.1.0. It is not necessary to bundle it with nanopb anymore.
298
299**Required actions:** Update `python-protobuf` to version
3003.1.0 or newer.
301
302**Error indications:** `ImportError: No module named compiler.plugin_pb2`
303
304### .options file is now always case-sensitive
305
306**Rationale:** Previously field names in `.options` file
307were case-sensitive on Linux and case-insensitive on Windows. This was
308by accident. Because `.proto` files are case-sensitive,
309`.options` files should be too.
310
311**Changes:** Now field names in `.options` are always
312case-sensitive, and matched by `fnmatchcase()` instead of
313`fnmatch()`.
314
315**Required actions:** If field names in `.options` are not
316capitalized the same as in `.proto`, they must be updated.
317
318### `CHAR_BIT` define is now needed
319
320**Rationale:** To check whether the platform has 8-bit or larger chars,
321the C standard `CHAR_BIT` macro is needed.
322
323**Changes:** `pb.h` now includes `limits.h` for this macro.
324
325**Required actions:** If your platform doesn't have `limits.h`
326available, you can define the macro in `pb_syshdr.h`. There is an
327example in `extra` directory.
328
329**Error indications:** `"Cannot find include file <limits.h>."` or
330`"Undefined identifier: CHAR_BIT."`
331
332### Strings must now always be null-terminated
333
334**Rationale:** Previously `pb_encode()` would accept non-terminated
335strings and assume that they are the full length of the defined array.
336However, `pb_decode()` would reject such messages because null
337terminator wouldn't fit in the array.
338
339**Changes:** `pb_encode()` will now return an error if null terminator
340is missing. Maximum encoded message size calculation is changed
341accordingly so that at most `max_size-1` strings are assumed. New field
342option `max_length` can be used to define the maximum string length,
343instead of the array size.
344
345**Required actions:** If your strings were previously filling the whole
346allocated array, increase the size of the field by 1.
347
348**Error indications:** `pb_encode()` returns error `unterminated string`.
349
350### Removal of per-field default value constants
351
352**Rationale:** Previously nanopb declared a
353`fieldname_default` constant variable for each field with a
354default value, and used these internally to initialize messages. This
355however used unnecessarily large amount of storage for the values. The
356variables were mostly for internal usage, but were available in the
357header file.
358
359**Changes:** Default values are now stored as an encoded protobuf
360message.
361
362**Required actions:** If your code previously used default constants, it
363will have to be adapted to take the default value in some other way,
364such as by defining
365`static const MyMessage msg_default = MyMessage_init_default;` and accessing
366`msg_default.fieldname`.
367
368**Error indications:** Compiler error about `fieldname_default` being undeclared.
369
370### Zero tag in message now raises error by default
371
372**Rationale:** Previously nanopb has allowed messages to be terminated
373by a null byte, which is read as zero tag value. Most other protobuf
374implementations don't support this, so it is not very useful feature.
375It has also been noted that this can complicate debugging issues with
376corrupted messages.
377
378**Changes:** `pb_decode()` now gives error when it
379encounters zero tag value. A new function `pb_decode_ex()`
380supports flag `PB_DECODE_NULLTERMINATED` that supports
381decoding null terminated messages.
382
383**Required actions:** If application uses null termination for messages,
384switch it to use `pb_decode_ex()` and
385`pb_encode_ex()`. If compatibility with 0.3.9.x is needed,
386there are also `pb_decode_nullterminated()` and
387`pb_encode_nullterminated()` macros, which work both in
3880.4.0 and 0.3.9.
389
390**Error indications:** Error message from `pb_decode()`: `zero_tag`.
391
392### Submessages now have has_field in proto3 mode
393
394**Rationale:** Previously nanopb considered proto3 submessages as
395present only when their contents was non-zero. Most other protobuf
396libraries allow explicit null state for submessages.
397
398**Changes:** Submessages now have separate `has_field` in
399proto3 mode also.
400
401**Required actions:** When using submessages in proto3 mode, user code
402must now set `mymsg.has_submsg = true` for each submessage
403that is present. Alternatively, the field option
404`proto3_singular_msgs` can be used to restore the old
405behavior.
406
407**Error indications:** Submessages do not get encoded.
408
409### PB_OLD_CALLBACK_STYLE option has been removed
410
411**Rationale:** Back in 2013, function signature for callbacks was
412changed. The `PB_OLD_CALLBACK_STYLE` option allowed
413compatibility with old code, but complicated code and testing because of
414the different options.
415
416**Changes:** `PB_OLD_CALLBACK_STYLE` option no-longer has
417any effect.
418
419**Required actions:** If `PB_OLD_CALLBACK_STYLE` option
420was in use previously, function signatures must be updated to use double
421pointers (`void**` and `void * const *`).
422
423**Error indications:** Assignment from incompatible pointer type.
424
425### protoc insertion points are no longer included by default
426
427**Rationale:** Protoc allows including comments in form
428`@@protoc_insertion_point` to identify locations for
429other plugins to insert their own extra content. Previously these were
430included by default, but they clutter the generated files and are rarely
431used.
432
433**Changes:** Insertion points are now included only when
434`--protoc-insertion-points` option is passed to the
435generator.
436
437Nanopb-0.3.9.4, 0.4.0 (2019-10-13)
438----------------------------------
439
440### Fix generation of min/max defines for enum types
441
442**Rationale:** Nanopb generator makes \#defines for enum minimum and
443maximum value. Previously these defines incorrectly had the first and
444last enum value, instead of the actual minimum and maximum. (issue
445#405)
446
447**Changes:** Minimum define now always has the smallest value, and
448maximum define always has the largest value.
449
450**Required actions:** If these defines are used and enum values in
451.proto file are not defined in ascending order, user code behaviour may
452change. Check that user code doesn\'t expect the old, incorrect
453first/last behaviour.
454
455### Fix undefined behavior related to bool fields
456
457**Rationale:** In C99, `bool` variables are not allowed to
458have other values than `true` and `false`.
459Compilers use this fact in optimization, and constructs like
460`int foo = msg.has_field ? 100 : 0;` will give unexpected results
461otherwise. Previously nanopb didn\'t enforce that decoded bool fields
462had valid values.
463
464**Changes:** Bool fields are now handled separately as
465`PB_LTYPE_BOOL`. The `LTYPE` descriptor
466numbers for other field types were renumbered.
467
468**Required actions:** Source code files must be recompiled, but
469regenerating `.pb.h`/`.pb.c` files from
470`.proto` is not required. If user code directly uses the
471nanopb internal field representation (search for
472`PB_LTYPE_VARINT` in source), it may need updating.
473
474Nanopb-0.3.9.1, 0.4.0 (2018-04-14)
475----------------------------------
476
477### Fix handling of string and bytes default values
478
479**Rationale:** Previously nanopb didn't properly decode special
480character escapes like `\200` emitted by protoc. This caused these
481escapes to end up verbatim in the default values in .pb.c file.
482
483**Changes:** Escapes are now decoded, and e.g. `\200` or `\x80`
484results in {0x80} for bytes field and `"\x80"` for string field.
485
486**Required actions:** If code has previously relied on `\` in default
487value being passed through verbatim, it must now be changed to `\\`.
488
489Nanopb-0.3.8 (2017-03-05)
490-------------------------
491
492### Fully drain substreams before closing
493
494**Rationale:** If the substream functions were called directly and the
495caller did not completely empty the substring before closing it, the
496parent stream would be put into an incorrect state.
497
498**Changes:** `pb_close_string_substream` can now error and returns a
499boolean.
500
501**Required actions:** Add error checking onto any call to
502`pb_close_string_substream`.
503
504### Change oneof format in .pb.c files
505
506**Rationale:** Previously two oneofs in a single message would be
507erroneously handled as part of the same union.
508
509**Changes:** Oneofs fields now use special `PB_DATAOFFSET_UNION`
510offset type in generated .pb.c files to distinguish whether they are the
511first or following field inside an union.
512
513**Required actions:** Regenerate `.pb.c/.pb.h` files with new nanopb
514version if oneofs are used.
515
516Nanopb-0.3.5 (2016-02-13)
517-------------------------
518
519### Add support for platforms without uint8_t
520
521**Rationale:** Some platforms cannot access 8-bit sized values directly,
522and do not define `uint8_t`. Nanopb previously didn\'t support these
523platforms.
524
525**Changes:** References to `uint8_t` were replaced with several
526alternatives, one of them being a new `pb_byte_t` typedef. This in
527turn uses `uint_least8_t` which means the smallest available type.
528
529**Required actions:** If your platform does not have a
530standards-compliant `stdint.h`, it may lack the definition for
531`[u]int_least8_t`. This must be added manually, example can be found
532in `extra/pb_syshdr.h`.
533
534**Error indications:** Compiler error: `"unknown type name 'uint_least8_t'"`.
535
536Nanopb-0.3.2 (2015-01-24)
537-------------------------
538
539### Add support for OneOfs
540
541**Rationale:** Previously nanopb did not support the `oneof` construct
542in `.proto` files. Those fields were generated as regular `optional`
543fields.
544
545**Changes:** OneOfs are now generated as C unions. Callback fields are
546not supported inside oneof and generator gives an error.
547
548**Required actions:** The generator option `no_unions` can be used to
549restore old behaviour and to allow callbacks to be used. To use unions,
550one change is needed: use `which_xxxx` field to detect which field is
551present, instead of `has_xxxx`. Compare the value against
552`MyStruct_myfield_tag`.
553
554**Error indications:** Generator error: `"Callback fields inside of
555oneof are not supported"`. Compiler error: `"Message"` has no member
556named `"has_xxxx"`.
557
558Nanopb-0.3.0 (2014-08-26)
559-------------------------
560
561### Separate field iterator logic to pb_common.c
562
563**Rationale:** Originally, the field iteration logic was simple enough
564to be duplicated in `pb_decode.c` and `pb_encode.c`. New field types
565have made the logic more complex, which required the creation of a new
566file to contain the common functionality.
567
568**Changes:** There is a new file, `pb_common.c`, which must be included
569in builds.
570
571**Required actions:** Add `pb_common.c` to build rules. This file is
572always required. Either `pb_decode.c` or `pb_encode.c` can still be
573left out if some functionality is not needed.
574
575**Error indications:** Linker error: undefined reference to
576`pb_field_iter_begin`, `pb_field_iter_next` or similar.
577
578### Change data type of field counts to pb_size_t
579
580**Rationale:** Often nanopb is used with small arrays, such as 255 items
581or less. Using a full `size_t` field to store the array count wastes
582memory if there are many arrays. There already exists parameters
583`PB_FIELD_16BIT` and `PB_FIELD_32BIT` which tell nanopb what is the
584maximum size of arrays in use.
585
586**Changes:** Generator will now use `pb_size_t` for the array
587`_count` fields. The size of the type will be controlled by the
588`PB_FIELD_16BIT` and `PB_FIELD_32BIT` compilation time options.
589
590**Required actions:** Regenerate all `.pb.h` files. In some cases casts
591to the `pb_size_t` type may need to be added in the user code when
592accessing the `_count` fields.
593
594**Error indications:** Incorrect data at runtime, crashes. But note that
595other changes in the same version already require regenerating the files
596and have better indications of errors, so this is only an issue for
597development versions.
598
599### Renamed some macros and identifiers
600
601**Rationale:** Some names in nanopb core were badly chosen and
602conflicted with ISO C99 reserved names or lacked a prefix. While they
603haven\'t caused trouble so far, it is reasonable to switch to
604non-conflicting names as these are rarely used from user code.
605
606**Changes:** The following identifier names have changed:
607
608 -   Macros:
609     -   STATIC_ASSERT(x) -> PB_STATIC_ASSERT(x)
610     -   UNUSED(x) -> PB_UNUSED(x)
611 -   Include guards:
612     -   PB_filename -> PB_filename_INCLUDED
613 -   Structure forward declaration tags:
614     -   _pb_field_t -> pb_field_s
615     -   _pb_bytes_array_t -> pb_bytes_array_s
616     -   _pb_callback_t -> pb_callback_s
617     -   _pb_extension_type_t -> pb_extension_type_s
618     -   _pb_extension_t -> pb_extension_s
619     -   _pb_istream_t -> pb_istream_s
620     -   _pb_ostream_t -> pb_ostream_s
621
622**Required actions:** Regenerate all `.pb.c` files. If you use any of
623the above identifiers in your application code, perform search-replace
624to the new name.
625
626**Error indications:** Compiler errors on lines with the macro/type
627names.
628
629Nanopb-0.2.9 (2014-08-09)
630-------------------------
631
632### Change semantics of generator -e option
633
634**Rationale:** Some compilers do not accept filenames with two dots
635(like in default extension .pb.c). The `-e` option to the generator
636allowed changing the extension, but not skipping the extra dot.
637
638**Changes:** The `-e` option in generator will no longer add the
639prepending dot. The default value has been adjusted accordingly to
640`.pb.c` to keep the default behaviour the same as before.
641
642**Required actions:** Only if using the generator -e option. Add dot
643before the parameter value on the command line.
644
645**Error indications:** File not found when trying to compile generated
646files.
647
648Nanopb-0.2.7 (2014-04-07)
649-------------------------
650
651### Changed pointer-type bytes field datatype
652
653**Rationale:** In the initial pointer encoding support since
654nanopb-0.2.5, the bytes type used a separate `pb_bytes_ptr_t` type to
655represent `bytes` fields. This made it easy to encode data from a
656separate, user-allocated buffer. However, it made the internal logic
657more complex and was inconsistent with the other types.
658
659**Changes:** Dynamically allocated bytes fields now have the
660`pb_bytes_array_t` type, just like statically allocated ones.
661
662**Required actions:** Only if using pointer-type fields with the bytes
663datatype. Change any access to `msg->field.size` to
664`msg->field->size`. Change any allocation to reserve space of amount
665`PB_BYTES_ARRAY_T_ALLOCSIZE(n)`. If the data pointer was begin
666assigned from external source, implement the field using a callback
667function instead.
668
669**Error indications:** Compiler error: unknown type name
670`pb_bytes_ptr_t`.
671
672Nanopb-0.2.4 (2013-11-07)
673-------------------------
674
675### Remove the NANOPB_INTERNALS compilation option
676
677**Rationale:** Having the option in the headers required the functions
678to be non-static, even if the option is not used. This caused errors on
679some static analysis tools.
680
681**Changes:** The `\#ifdef` and associated functions were removed from
682the header.
683
684**Required actions:** Only if the `NANOPB_INTERNALS` option was
685previously used. Actions are as listed under nanopb-0.1.3 and
686nanopb-0.1.6.
687
688**Error indications:** Compiler warning: implicit declaration of
689function `pb_dec_string`, `pb_enc_string`, or similar.
690
691Nanopb-0.2.1 (2013-04-14)
692-------------------------
693
694### Callback function signature
695
696**Rationale:** Previously the auxiliary data to field callbacks was
697passed as `void*`. This allowed passing of any data, but made it
698unnecessarily complex to return a pointer from callback.
699
700**Changes:** The callback function parameter was changed to `void**`.
701
702**Required actions:** You can continue using the old callback style by
703defining `PB_OLD_CALLBACK_STYLE`. Recommended action is to:
704
705-   Change the callback signatures to contain `void**` for decoders and `void * const *` for encoders.
706-   Change the callback function body to use **arg` instead of `arg`.
707
708**Error indications:** Compiler warning: assignment from incompatible
709pointer type, when initializing `funcs.encode` or `funcs.decode`.
710
711Nanopb-0.2.0 (2013-03-02)
712-------------------------
713
714### Reformatted generated .pb.c file using macros
715
716**Rationale:** Previously the generator made a list of C `pb_field_t`
717initializers in the .pb.c file. This led to a need to regenerate all
718.pb.c files after even small changes to the `pb_field_t` definition.
719
720**Changes:** Macros were added to pb.h which allow for cleaner
721definition of the .pb.c contents. By changing the macro definitions,
722changes to the field structure are possible without breaking
723compatibility with old .pb.c files.
724
725**Required actions:** Regenerate all .pb.c files from the .proto
726sources.
727
728**Error indications:** Compiler warning: implicit declaration of
729function `pb_delta_end`.
730
731### Changed pb_type_t definitions
732
733**Rationale:** The `pb_type_t` was previously an enumeration type.
734This caused warnings on some compilers when using bitwise operations to
735set flags inside the values.
736
737**Changes:** The `pb_type_t` was changed to *typedef uint8_t*. The
738values were changed to `#define`. Some value names were changed for
739consistency.
740
741**Required actions:** Only if you directly access the
742`pb_field_t` contents in your own code, something which is
743not usually done. Needed changes:
744
745-   Change `PB_HTYPE_ARRAY` to `PB_HTYPE_REPEATED`.
746-   Change `PB_HTYPE_CALLBACK` to `PB_ATYPE()` and `PB_ATYPE_CALLBACK`.
747
748**Error indications:** Compiler error: `PB_HTYPE_ARRAY` or
749`PB_HTYPE_CALLBACK` undeclared.
750
751Nanopb-0.1.6 (2012-09-02)
752-------------------------
753
754### Refactored field decoder interface
755
756**Rationale:** Similarly to field encoders in nanopb-0.1.3.
757
758**Changes:** New functions with names `pb_decode_*` were added.
759
760**Required actions:** By defining NANOPB_INTERNALS, you can still keep
761using the old functions. Recommended action is to replace any calls with
762the newer `pb_decode_*` equivalents.
763
764**Error indications:** Compiler warning: implicit declaration of
765function `pb_dec_string`, `pb_dec_varint`, `pb_dec_submessage` or
766similar.
767
768Nanopb-0.1.3 (2012-06-12)
769-------------------------
770
771### Refactored field encoder interface
772
773**Rationale:** The old `pb_enc_*` functions were designed mostly for
774the internal use by the core. Because they are internally accessed
775through function pointers, their signatures had to be common. This led
776to a confusing interface for external users.
777
778**Changes:** New functions with names `pb_encode_*` were added. These
779have easier to use interfaces. The old functions are now only thin
780wrappers for the new interface.
781
782**Required actions:** By defining NANOPB_INTERNALS, you can still keep
783using the old functions. Recommended action is to replace any calls with
784the newer `pb_encode_*` equivalents.
785
786**Error indications:** Compiler warning: implicit declaration of
787function `pb_enc_string`, *pb_enc_varint,`pb_enc_submessage\` or
788similar.
789