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
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user