aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-10-29 16:56:45 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-10-29 16:56:45 +0200
commitc3fa362653480159dff15c074f59c5fab301dd0e (patch)
tree35ffa393dc07d6e36d272e101201c8c0cf34b756
parentbffd3a9accd748f20ad4a2d75942893684b90d81 (diff)
Give names to generated structures to allow forward declaration.
Update issue 39 Status: FixedInGit
-rw-r--r--generator/nanopb_generator.py4
-rw-r--r--pb.h6
2 files changed, 6 insertions, 4 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index b9018aeb..1c214222 100644
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -75,7 +75,7 @@ class Enum:
self.values = [(self.names + x.name, x.number) for x in desc.value]
def __str__(self):
- result = 'typedef enum {\n'
+ result = 'typedef enum _%s {\n' % self.names
result += ',\n'.join([" %s = %d" % x for x in self.values])
result += '\n} %s;' % self.names
return result
@@ -276,7 +276,7 @@ class Message:
return [str(field.ctype) for field in self.fields]
def __str__(self):
- result = 'typedef struct {\n'
+ result = 'typedef struct _%s {\n' % self.name
result += '\n'.join([str(f) for f in self.ordered_fields])
result += '\n} %s;' % self.name
return result
diff --git a/pb.h b/pb.h
index dce8df30..72b41963 100644
--- a/pb.h
+++ b/pb.h
@@ -148,10 +148,12 @@ struct _pb_field_t {
* It has the number of bytes in the beginning, and after that an array.
* Note that actual structs used will have a different length of bytes array.
*/
-typedef struct {
+struct _pb_bytes_array_t {
size_t size;
uint8_t bytes[1];
-} pb_bytes_array_t;
+};
+
+typedef struct _pb_bytes_array_t pb_bytes_array_t;
/* This structure is used for giving the callback function.
* It is stored in the message structure and filled in by the method that