diff options
Diffstat (limited to 'typedefs_cgen.c')
-rw-r--r-- | typedefs_cgen.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/typedefs_cgen.c b/typedefs_cgen.c index be2785d..422e6cd 100644 --- a/typedefs_cgen.c +++ b/typedefs_cgen.c @@ -36,7 +36,7 @@ static bool typedefs_decl(CGenerator *g, Declaration *d) { d->c.ids = allocr_calloc(g->allocr, arr_len(d->idents), sizeof *d->c.ids); /* generate typedef */ IdentID id = 0; - if (g->block != NULL) id = d->c.ids[idx] = g->ident_counter++; + if (g->block != NULL || g->fn != NULL) id = d->c.ids[idx] = g->ident_counter++; if (val->type->kind == TYPE_STRUCT) { /* we'll actually define the struct later; here we can just declare it */ cgen_write(g, "struct "); @@ -54,7 +54,7 @@ static bool typedefs_decl(CGenerator *g, Declaration *d) { cgen_write(g, "typedef "); if (!cgen_type_pre(g, val->type, d->where)) return false; cgen_write(g, " "); - if (g->block == NULL) { + if (g->block == NULL && g->fn == NULL) { /* we can refer to this by its name */ cgen_ident(g, i); } else { |