diff options
| author | Soren <soren@disroot.org> | 2020-08-16 12:08:34 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-08-18 00:31:29 -0400 |
| commit | 60ea87340e7a7157bedbb43d60804ff0fb191ef9 (patch) | |
| tree | 5bfcd7471bb25a8adb6c3104f869f8dd42272f78 /src/codegen.cpp | |
| parent | 8d6004769731deaabbed014c79b4066bd9e380e8 (diff) | |
| download | zig-60ea87340e7a7157bedbb43d60804ff0fb191ef9.tar.gz zig-60ea87340e7a7157bedbb43d60804ff0fb191ef9.zip | |
Fix opaque structs and C++ mangling
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 14 |
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)) |
