1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: declare empty structs correctly

This commit is contained in:
Alexey 2020-04-05 13:31:25 +03:00 committed by GitHub
parent de701ccfac
commit 9c1eaaeb49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2168,11 +2168,15 @@ fn (g mut Gen) write_types(types []table.TypeSymbol) {
info := typ.info as table.Struct
// g.definitions.writeln('typedef struct {')
g.definitions.writeln('struct $name {')
if info.fields.len > 0 {
for field in info.fields {
type_name := g.typ(field.typ)
field_name := c_name(field.name)
g.definitions.writeln('\t$type_name $field_name;')
}
} else {
g.definitions.writeln('EMPTY_STRUCT_DECLARATION;')
}
// g.definitions.writeln('} $name;\n')
//
g.definitions.writeln('};\n')