From 3ed219382e55885a66a462db1cf06170ce80e606 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Tue, 19 Aug 2014 17:55:44 +0300 Subject: Add #if guard for .pb.h version. The version in PB_PROTO_HEADER_VERSION can be bumped whenever there is a breaking change to the generated files, and it will then alert to the difference. Update issue 129 Status: FixedInGit --- generator/nanopb_generator.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'generator') diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 50108148..5d2a360d 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -361,7 +361,7 @@ class Field: '''Return the pb_field_t initializer to use in the constant array. prev_field_name is the name of the previous field or None. ''' - result = ' PB_FIELD2(%3d, ' % self.tag + result = ' PB_FIELD(%3d, ' % self.tag result += '%-8s, ' % self.pbtype result += '%s, ' % self.rules result += '%-8s, ' % self.allocation @@ -782,6 +782,11 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio yield options.genformat % (noext + options.extension + '.h') yield '\n' + yield '#if PB_PROTO_HEADER_VERSION != 30\n' + yield '#error Regenerate this file with the current version of nanopb generator.\n' + yield '#endif\n' + yield '\n' + yield '#ifdef __cplusplus\n' yield 'extern "C" {\n' yield '#endif\n\n' @@ -854,6 +859,11 @@ def generate_source(headername, enums, messages, extensions, options): yield options.genformat % (headername) yield '\n' + yield '#if PB_PROTO_HEADER_VERSION != 30\n' + yield '#error Regenerate this file with the current version of nanopb generator.\n' + yield '#endif\n' + yield '\n' + for msg in messages: yield msg.default_decl(False) -- cgit 1.2.3-korg