From 82e55f6515d7f4e10e42b8810ef2a48898526aca Mon Sep 17 00:00:00 2001 From: James McKaskill Date: Thu, 12 Sep 2013 14:26:22 -0400 Subject: [PATCH] declare enums first --- compiler/capnpc-c.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/capnpc-c.c b/compiler/capnpc-c.c index db94dc9..fcc9d11 100644 --- a/compiler/capnpc-c.c +++ b/compiler/capnpc-c.c @@ -1144,20 +1144,20 @@ int main() { declare(file_node, "typedef struct {capn_ptr p;} %s_list;\n", 1); for (n = file_node->file_nodes; n != NULL; n = n->next_file_node) { - switch (n->n.which) { - case Node_struct: - if (!n->n._struct.isGroup) { - define_struct(n); - } - break; - case Node_enum: + if (n->n.which == Node_enum) { define_enum(n); - break; - case Node_const: + } + } + + for (n = file_node->file_nodes; n != NULL; n = n->next_file_node) { + if (n->n.which == Node_const) { define_const(n); - break; - default: - break; + } + } + + for (n = file_node->file_nodes; n != NULL; n = n->next_file_node) { + if (n->n.which == Node_struct && !n->n._struct.isGroup) { + define_struct(n); } }