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

cgen: fix [packed] struct support for tcc

This commit is contained in:
Delyan Angelov 2022-09-04 07:13:53 +03:00
parent 5e1a2f6f50
commit dd78620b31
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 4 additions and 7 deletions

View File

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

View File

@ -313,6 +313,10 @@ fn (mut g Gen) struct_decl(s ast.Struct, name string, is_anon bool) {
pre_pragma += '#pragma pack(push, $attr.arg)\n'
post_pragma += '#pragma pack(pop)'
}
'packed' {
pre_pragma += '#pragma pack(push, 1)\n'
post_pragma += '#pragma pack(pop)'
}
else {}
}
}