aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgenerator/nanopb_generator.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index bc9e9da8..0e9b018b 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -197,6 +197,10 @@ class Enum:
result += ' %s;' % self.names
+ result += '\n#define _%s_MIN %s' % (self.names, self.values[0][0])
+ result += '\n#define _%s_MAX %s' % (self.names, self.values[-1][0])
+ result += '\n#define _%s_ARRAYSIZE ((%s)(%s+1))' % (self.names, self.names, self.values[-1][0])
+
if not self.options.long_names:
# Define the long names always so that enum value references
# from other files work properly.