aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 1bd8d5b7bc..36ed520069 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -10252,9 +10252,11 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_e
gen_h->types_to_declare.append(type_entry);
return;
case ZigTypeIdStruct:
- for (uint32_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {
- TypeStructField *field = type_entry->data.structure.fields[i];
- prepend_c_type_to_decl_list(g, gen_h, field->type_entry);
+ if(type_entry->data.structure.layout == ContainerLayoutExtern) {
+ for (uint32_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {
+ TypeStructField *field = type_entry->data.structure.fields[i];
+ prepend_c_type_to_decl_list(g, gen_h, field->type_entry);
+ }
}
gen_h->types_to_declare.append(type_entry);
return;
@@ -10687,21 +10689,19 @@ static void gen_h_file(CodeGen *g) {
fprintf(out_h, "\n");
}
- fprintf(out_h, "%s", buf_ptr(&types_buf));
-
fprintf(out_h, "#ifdef __cplusplus\n");
fprintf(out_h, "extern \"C\" {\n");
fprintf(out_h, "#endif\n");
fprintf(out_h, "\n");
+ fprintf(out_h, "%s", buf_ptr(&types_buf));
fprintf(out_h, "%s\n", buf_ptr(&fns_buf));
+ fprintf(out_h, "%s\n", buf_ptr(&vars_buf));
fprintf(out_h, "#ifdef __cplusplus\n");
fprintf(out_h, "} // extern \"C\"\n");
fprintf(out_h, "#endif\n\n");
- fprintf(out_h, "%s\n", buf_ptr(&vars_buf));
-
fprintf(out_h, "#endif // %s\n", buf_ptr(ifdef_dance_name));
if (fclose(out_h))