Closed GoogleCodeExporter closed 9 years ago
There is a backwards compatible way to add the error codes:
#ifdef PB_USE_ERROR_CODES
/* New api that uses error codes */
#define PB_OK 0
#define PB_IO_ERROR 1 /* Error in stream input/output */
#define PB_FMT_ERROR 2 /* Message binary format is invalid */
#define PB_SIZE_ERROR 3 /* Field exceeds max_size or max_count */
#else
/* Old api that uses true/false */
#define PB_OK true
#define PB_IO_ERROR false
#define PB_FMT_ERROR false
#define PB_SIZE_ERROR false
#endif
This way code written like if (pb_encode(...) == PB_OK) will work with
either configuration, and code written like if (pb_encode(...)) will work in
the legacy config.
Original comment by Petteri.Aimonen
on 31 Jul 2012 at 4:24
Another way would be to add the error code to the pb_istream/pb_ostream
structure. Would not require any changes to the current applications.
Original comment by Petteri.Aimonen
on 31 Jul 2012 at 4:33
This issue was updated by revision 0fb5e5e06832.
Original comment by Petteri.Aimonen
on 24 Aug 2012 at 6:23
Please consider to apply this (trivial) patch.
Original comment by jens.ste...@gmail.com
on 26 Nov 2012 at 11:47
Attachments:
Thanks, applied:
https://code.google.com/p/nanopb/source/detail?r=068de05c51b7b46e33ef87b8d78c9dd
a6704abc8
Original comment by Petteri.Aimonen
on 27 Nov 2012 at 5:56
This issue was updated by revision 035264711897.
Original comment by Petteri.Aimonen
on 9 Mar 2013 at 12:49
Fix released in 0.2.1
Original comment by Petteri.Aimonen
on 14 Apr 2013 at 7:19
Original issue reported on code.google.com by
Petteri.Aimonen
on 1 Mar 2012 at 10:47