authorgravatar for soren@disroot.orgSoren <soren@disroot.org> 2020-08-16 12:08:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-18 00:31:29-04:00
log60ea87340e7a7157bedbb43d60804ff0fb191ef9
tree5bfcd7471bb25a8adb6c3104f869f8dd42272f78
parent8d6004769731deaabbed014c79b4066bd9e380e8

Fix opaque structs and C++ mangling


1 files changed, 7 insertions(+), 7 deletions(-)

src/codegen.cpp+7-7
......@@ -10252,9 +10252,11 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_e
1025210252 gen_h->types_to_declare.append(type_entry);
1025310253 return;
1025410254 case ZigTypeIdStruct:
10255 for (uint32_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {
10256 TypeStructField *field = type_entry->data.structure.fields[i];
10257 prepend_c_type_to_decl_list(g, gen_h, field->type_entry);
10255 if(type_entry->data.structure.layout == ContainerLayoutExtern) {
10256 for (uint32_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {
10257 TypeStructField *field = type_entry->data.structure.fields[i];
10258 prepend_c_type_to_decl_list(g, gen_h, field->type_entry);
10259 }
1025810260 }
1025910261 gen_h->types_to_declare.append(type_entry);
1026010262 return;
......@@ -10687,21 +10689,19 @@ static void gen_h_file(CodeGen *g) {
1068710689 fprintf(out_h, "\n");
1068810690 }
1068910691
10690 fprintf(out_h, "%s", buf_ptr(&types_buf));
10691
1069210692 fprintf(out_h, "#ifdef __cplusplus\n");
1069310693 fprintf(out_h, "extern \"C\" {\n");
1069410694 fprintf(out_h, "#endif\n");
1069510695 fprintf(out_h, "\n");
1069610696
10697 fprintf(out_h, "%s", buf_ptr(&types_buf));
1069710698 fprintf(out_h, "%s\n", buf_ptr(&fns_buf));
10699 fprintf(out_h, "%s\n", buf_ptr(&vars_buf));
1069810700
1069910701 fprintf(out_h, "#ifdef __cplusplus\n");
1070010702 fprintf(out_h, "} // extern \"C\"\n");
1070110703 fprintf(out_h, "#endif\n\n");
1070210704
10703 fprintf(out_h, "%s\n", buf_ptr(&vars_buf));
10704
1070510705 fprintf(out_h, "#endif // %s\n", buf_ptr(ifdef_dance_name));
1070610706
1070710707 if (fclose(out_h))