summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generator/nanopb_generator.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index c3b5fbee..663745a1 100644
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -300,6 +300,12 @@ class Message:
def __str__(self):
result = 'typedef struct _%s {\n' % self.name
+
+ if not self.ordered_fields:
+ # Empty structs are not allowed in C standard.
+ # Therefore add a dummy field if an empty message occurs.
+ result += ' uint8_t dummy_field;'
+
result += '\n'.join([str(f) for f in self.ordered_fields])
result += '\n}'