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...@@ -10252,9 +10252,11 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_e
10252 gen_h->types_to_declare.append(type_entry);10252 gen_h->types_to_declare.append(type_entry);
10253 return;10253 return;
10254 case ZigTypeIdStruct:10254 case ZigTypeIdStruct:
10255 for (uint32_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {10255 if(type_entry->data.structure.layout == ContainerLayoutExtern) {
10256 TypeStructField *field = type_entry->data.structure.fields[i];10256 for (uint32_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) {
10257 prepend_c_type_to_decl_list(g, gen_h, field->type_entry);10257 TypeStructField *field = type_entry->data.structure.fields[i];
10258 prepend_c_type_to_decl_list(g, gen_h, field->type_entry);
10259 }
10258 }10260 }
10259 gen_h->types_to_declare.append(type_entry);10261 gen_h->types_to_declare.append(type_entry);
10260 return;10262 return;
...@@ -10687,21 +10689,19 @@ static void gen_h_file(CodeGen *g) {...@@ -10687,21 +10689,19 @@ static void gen_h_file(CodeGen *g) {
10687 fprintf(out_h, "\n");10689 fprintf(out_h, "\n");
10688 }10690 }
1068910691
10690 fprintf(out_h, "%s", buf_ptr(&types_buf));
10691
10692 fprintf(out_h, "#ifdef __cplusplus\n");10692 fprintf(out_h, "#ifdef __cplusplus\n");
10693 fprintf(out_h, "extern \"C\" {\n");10693 fprintf(out_h, "extern \"C\" {\n");
10694 fprintf(out_h, "#endif\n");10694 fprintf(out_h, "#endif\n");
10695 fprintf(out_h, "\n");10695 fprintf(out_h, "\n");
1069610696
10697 fprintf(out_h, "%s", buf_ptr(&types_buf));
10697 fprintf(out_h, "%s\n", buf_ptr(&fns_buf));10698 fprintf(out_h, "%s\n", buf_ptr(&fns_buf));
10699 fprintf(out_h, "%s\n", buf_ptr(&vars_buf));
1069810700
10699 fprintf(out_h, "#ifdef __cplusplus\n");10701 fprintf(out_h, "#ifdef __cplusplus\n");
10700 fprintf(out_h, "} // extern \"C\"\n");10702 fprintf(out_h, "} // extern \"C\"\n");
10701 fprintf(out_h, "#endif\n\n");10703 fprintf(out_h, "#endif\n\n");
1070210704
10703 fprintf(out_h, "%s\n", buf_ptr(&vars_buf));
10704
10705 fprintf(out_h, "#endif // %s\n", buf_ptr(ifdef_dance_name));10705 fprintf(out_h, "#endif // %s\n", buf_ptr(ifdef_dance_name));
1070610706
10707 if (fclose(out_h))10707 if (fclose(out_h))