Add a dummy field if struct would otherwise be empty.

Update issue 64
Status: FixedInGit
This commit is contained in:
Petteri Aimonen
2013-03-06 18:02:57 +02:00
parent 64bf72d73d
commit 5522e02133

View File

@@ -300,6 +300,12 @@ class Message:
def __str__(self): def __str__(self):
result = 'typedef struct _%s {\n' % self.name 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'.join([str(f) for f in self.ordered_fields])
result += '\n}' result += '\n}'