What steps will reproduce the problem?
1. Write .proto file which includes a message with no fields.
2. Compile that .proto file.
The resulting generated .h file will contain empty structs. These are not
strictly allowed in C99 (eg. see
http://stackoverflow.com/questions/2849901/empty-struct-definitions-illegal-in-c
-but-not-c#2849982 ). GCC allows it anyway, but MSVC does not.
Here's a possible patch which adds a dummy field to such structs:
--- nanopb/generator/nanopb_generator_old.py 2013-03-07 02:24:11 +1100
+++ nanopb/generator/nanopb_generator_new.py 2013-03-07 02:24:14 +1100
@@ -300,6 +300,8 @@
def __str__(self):
result = 'typedef struct _%s {\n' % self.name
+ if len(self.ordered_fields) == 0:
+ result += ' uint8_t dummy; // structs in C must be
non-empty'
result += '\n'.join([str(f) for f in self.ordered_fields])
result += '\n}'
Original issue reported on code.google.com by someon...@gmail.com on 6 Mar 2013 at 3:56
Original issue reported on code.google.com by
someon...@gmail.com
on 6 Mar 2013 at 3:56