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:
parent
de701ccfac
commit
9c1eaaeb49
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user