cgen: [packed] struct attribute

pull/9608/head
Alexander Medvednikov 2021-04-05 06:49:43 +03:00
parent 22b4ac2266
commit 77d8336db9
1 changed files with 6 additions and 1 deletions

View File

@ -1247,7 +1247,12 @@ fn (mut g Gen) stmt(node ast.Stmt) {
if node.is_union {
g.typedefs.writeln('typedef union $name $name;')
} else {
g.typedefs.writeln('typedef struct $name $name;')
attrs := if node.attrs.contains('packed') {
'__attribute__((__packed__))'
} else {
''
}
g.typedefs.writeln('typedef struct $attrs $name $name;')
}
}
ast.TypeDecl {