aboutsummaryrefslogtreecommitdiffstats
path: root/generator/nanopb_generator.py
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-03-06 18:02:57 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-03-06 18:02:57 +0200
commit5522e02133be7d9dfd2f350f2774dfc0abc15686 (patch)
treee6bed153dcdb71e13861e9247dc56ce6d61a1fb2 /generator/nanopb_generator.py
parent64bf72d73d2b1a9bc3be1f7bba117a9664de7c1f (diff)
Add a dummy field if struct would otherwise be empty.
Update issue 64 Status: FixedInGit
Diffstat (limited to 'generator/nanopb_generator.py')
-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}'