aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-08-19 17:55:44 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-08-19 17:55:44 +0300
commit3ed219382e55885a66a462db1cf06170ce80e606 (patch)
tree980a5e89ff412f6c0dfc66adbf5134a60350fe36 /generator
parentbe0b9e047a007685aa10a268f9bf856e9a52ef58 (diff)
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
Diffstat (limited to 'generator')
-rwxr-xr-xgenerator/nanopb_generator.py12
1 files changed, 11 insertions, 1 deletions
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)