| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 | =====================================Nanopb: Migration from older versions=====================================.. include :: menu.rstThis document details all the breaking changes that have been made to nanopbsince its initial release. For each change, the rationale and requiredmodifications of user applications are explained. Also any error indicationsare included, in order to make it easier to find this document... contents ::Nanopb-0.3.5 (2016-02-13)=========================Add support for platforms without uint8_t-----------------------------------------**Rationale:** Some platforms cannot access 8-bit sized values directly, anddo not define *uint8_t*. Nanopb previously didn't support these platforms.**Changes:** References to *uint8_t* were replaced with several alternatives,one of them being a new *pb_byte_t* typedef. This in turn uses *uint_least8_t*which means the smallest available type.**Required actions:** If your platform does not have a standards-compliant*stdint.h*, it may lack the definition for *[u]int_least8_t*. This must beadded manually, example can be found in *extra/pb_syshdr.h*.**Error indications:** Compiler error: "unknown type name 'uint_least8_t'".Nanopb-0.3.2 (2015-01-24)=========================Add support for OneOfs----------------------**Rationale:** Previously nanopb did not support the *oneof* construct in*.proto* files. Those fields were generated as regular *optional* fields.**Changes:** OneOfs are now generated as C unions. Callback fields are notsupported inside oneof and generator gives an error.**Required actions:** The generator option *no_unions* can be used to restore oldbehaviour and to allow callbacks to be used. To use unions, one change isneeded: use *which_xxxx* field to detect which field is present, insteadof *has_xxxx*. Compare the value against *MyStruct_myfield_tag*.**Error indications:** Generator error: "Callback fields inside of oneof arenot supported". Compiler error: "Message" has no member named "has_xxxx".Nanopb-0.3.0 (2014-08-26)=========================Separate field iterator logic to pb_common.c--------------------------------------------**Rationale:** Originally, the field iteration logic was simple enough to beduplicated in *pb_decode.c* and *pb_encode.c*. New field types have made thelogic more complex, which required the creation of a new file to contain thecommon functionality.**Changes:** There is a new file, *pb_common.c*, which must be included inbuilds.**Required actions:** Add *pb_common.c* to build rules. This file is alwaysrequired. Either *pb_decode.c* or *pb_encode.c* can still be left out if somefunctionality is not needed.**Error indications:** Linker error: undefined reference to*pb_field_iter_begin*, *pb_field_iter_next* or similar.Change data type of field counts to pb_size_t---------------------------------------------**Rationale:** Often nanopb is used with small arrays, such as 255 items orless. Using a full *size_t* field to store the array count wastes memory ifthere are many arrays. There already exists parameters *PB_FIELD_16BIT* and*PB_FIELD_32BIT* which tell nanopb what is the maximum size of arrays in use.**Changes:** Generator will now use *pb_size_t* for the array *_count* fields.The size of the type will be controlled by the *PB_FIELD_16BIT* and*PB_FIELD_32BIT* compilation time options.**Required actions:** Regenerate all *.pb.h* files. In some cases casts to the*pb_size_t* type may need to be added in the user code when accessing the*_count* fields.**Error indications:** Incorrect data at runtime, crashes. But note that otherchanges in the same version already require regenerating the files and havebetter indications of errors, so this is only an issue for developmentversions.Renamed some macros and identifiers-----------------------------------**Rationale:** Some names in nanopb core were badly chosen and conflicted withISO C99 reserved names or lacked a prefix. While they haven't caused troubleso far, it is reasonable to switch to non-conflicting names as these are rarelyused from user code.**Changes:** The following identifier names have changed:  * Macros:      * STATIC_ASSERT(x) -> PB_STATIC_ASSERT(x)    * UNUSED(x) -> PB_UNUSED(x)    * Include guards:      * _PB_filename_ -> PB_filename_INCLUDED    * Structure forward declaration tags:      * _pb_field_t -> pb_field_s    * _pb_bytes_array_t -> pb_bytes_array_s    * _pb_callback_t -> pb_callback_s    * _pb_extension_type_t -> pb_extension_type_s    * _pb_extension_t -> pb_extension_s    * _pb_istream_t -> pb_istream_s    * _pb_ostream_t -> pb_ostream_s**Required actions:** Regenerate all *.pb.c* files. If you use any of the aboveidentifiers in your application code, perform search-replace to the new name.**Error indications:** Compiler errors on lines with the macro/type names.Nanopb-0.2.9 (2014-08-09)=========================Change semantics of generator -e option---------------------------------------**Rationale:** Some compilers do not accept filenames with two dots (likein default extension .pb.c). The *-e* option to the generator allowed changingthe extension, but not skipping the extra dot.**Changes:** The *-e* option in generator will no longer add the prependingdot. The default value has been adjusted accordingly to *.pb.c* to keep thedefault behaviour the same as before.**Required actions:** Only if using the generator -e option. Add dot beforethe parameter value on the command line.**Error indications:** File not found when trying to compile generated files.Nanopb-0.2.7 (2014-04-07)=========================Changed pointer-type bytes field datatype-----------------------------------------**Rationale:** In the initial pointer encoding support since nanopb-0.2.5,the bytes type used a separate *pb_bytes_ptr_t* type to represent *bytes*fields. This made it easy to encode data from a separate, user-allocatedbuffer. However, it made the internal logic more complex and was inconsistentwith the other types.**Changes:** Dynamically allocated bytes fields now have the *pb_bytes_array_t*type, just like statically allocated ones.**Required actions:** Only if using pointer-type fields with the bytes datatype.Change any access to *msg->field.size* to *msg->field->size*. Change anyallocation to reserve space of amount *PB_BYTES_ARRAY_T_ALLOCSIZE(n)*. If thedata pointer was begin assigned from external source, implement the field usinga callback function instead.**Error indications:** Compiler error: unknown type name *pb_bytes_ptr_t*.Nanopb-0.2.4 (2013-11-07)=========================Remove the NANOPB_INTERNALS compilation option----------------------------------------------**Rationale:** Having the option in the headers required the functions tobe non-static, even if the option is not used. This caused errors on somestatic analysis tools.**Changes:** The *#ifdef* and associated functions were removed from theheader.**Required actions:** Only if the *NANOPB_INTERNALS* option was previouslyused. Actions are as listed under nanopb-0.1.3 and nanopb-0.1.6.**Error indications:** Compiler warning: implicit declaration of function*pb_dec_string*, *pb_enc_string*, or similar.Nanopb-0.2.1 (2013-04-14)=========================Callback function signature---------------------------**Rationale:** Previously the auxilary data to field callbacks was passedas *void\**. This allowed passing of any data, but made it unnecessarilycomplex to return a pointer from callback.**Changes:** The callback function parameter was changed to *void\*\**.**Required actions:** You can continue using the old callback style bydefining *PB_OLD_CALLBACK_STYLE*. Recommended action is to:  * Change the callback signatures to contain *void\*\** for decoders and    *void \* const \** for encoders.  * Change the callback function body to use *\*arg* instead of *arg*.**Error indications:** Compiler warning: assignment from incompatiblepointer type, when initializing *funcs.encode* or *funcs.decode*.Nanopb-0.2.0 (2013-03-02)=========================Reformatted generated .pb.c file using macros---------------------------------------------**Rationale:** Previously the generator made a list of C *pb_field_t*initializers in the .pb.c file. This led to a need to regenerate all .pb.cfiles after even small changes to the *pb_field_t* definition.**Changes:** Macros were added to pb.h which allow for cleaner definitionof the .pb.c contents. By changing the macro definitions, changes to thefield structure are possible without breaking compatibility with old .pb.cfiles.**Required actions:** Regenerate all .pb.c files from the .proto sources.**Error indications:** Compiler warning: implicit declaration of function*pb_delta_end*.Changed pb_type_t definitions-----------------------------**Rationale:** The *pb_type_t* was previously an enumeration type. Thiscaused warnings on some compilers when using bitwise operations to set flagsinside the values.**Changes:** The *pb_type_t* was changed to *typedef uint8_t*. The valueswere changed to *#define*. Some value names were changed for consistency.**Required actions:** Only if you directly access the `pb_field_t` contentsin your own code, something which is not usually done. Needed changes:  * Change *PB_HTYPE_ARRAY* to *PB_HTYPE_REPEATED*.  * Change *PB_HTYPE_CALLBACK* to *PB_ATYPE()* and *PB_ATYPE_CALLBACK*.**Error indications:** Compiler error: *PB_HTYPE_ARRAY* or *PB_HTYPE_CALLBACK*undeclared.Nanopb-0.1.6 (2012-09-02)=========================Refactored field decoder interface----------------------------------**Rationale:** Similarly to field encoders in nanopb-0.1.3.**Changes:** New functions with names *pb_decode_\** were added.**Required actions:** By defining NANOPB_INTERNALS, you can still keep usingthe old functions. Recommended action is to replace any calls with the newer*pb_decode_\** equivalents.**Error indications:** Compiler warning: implicit declaration of function*pb_dec_string*, *pb_dec_varint*, *pb_dec_submessage* or similar.Nanopb-0.1.3 (2012-06-12)=========================Refactored field encoder interface----------------------------------**Rationale:** The old *pb_enc_\** functions were designed mostly for theinternal use by the core. Because they are internally accessed throughfunction pointers, their signatures had to be common. This led to a confusinginterface for external users.**Changes:** New functions with names *pb_encode_\** were added. These haveeasier to use interfaces. The old functions are now only thin wrappers forthe new interface.**Required actions:** By defining NANOPB_INTERNALS, you can still keep usingthe old functions. Recommended action is to replace any calls with the newer*pb_encode_\** equivalents.**Error indications:** Compiler warning: implicit declaration of function*pb_enc_string*, *pb_enc_varint, *pb_enc_submessage* or similar.
 |