cgen: declare empty structs correctly
parent
de701ccfac
commit
9c1eaaeb49
|
@ -2168,11 +2168,15 @@ fn (g mut Gen) write_types(types []table.TypeSymbol) {
|
||||||
info := typ.info as table.Struct
|
info := typ.info as table.Struct
|
||||||
// g.definitions.writeln('typedef struct {')
|
// g.definitions.writeln('typedef struct {')
|
||||||
g.definitions.writeln('struct $name {')
|
g.definitions.writeln('struct $name {')
|
||||||
|
if info.fields.len > 0 {
|
||||||
for field in info.fields {
|
for field in info.fields {
|
||||||
type_name := g.typ(field.typ)
|
type_name := g.typ(field.typ)
|
||||||
field_name := c_name(field.name)
|
field_name := c_name(field.name)
|
||||||
g.definitions.writeln('\t$type_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('} $name;\n')
|
||||||
//
|
//
|
||||||
g.definitions.writeln('};\n')
|
g.definitions.writeln('};\n')
|
||||||
|
|
Loading…
Reference in New Issue