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

cgen: fix msvc packed attr (#18437)

This commit is contained in:
Felipe Pena 2023-06-14 04:44:48 -03:00 committed by GitHub
parent 530f73b927
commit 23da2128d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -3798,7 +3798,11 @@ fn (mut g Gen) enum_decl(node ast.EnumDecl) {
g.enum_typedefs.writeln(', // ${cur_value}') g.enum_typedefs.writeln(', // ${cur_value}')
cur_enum_offset++ cur_enum_offset++
} }
packed_attribute := if node.typ != ast.int_type { '__attribute__((packed))' } else { '' } packed_attribute := if !g.is_cc_msvc && node.typ != ast.int_type {
'__attribute__((packed))'
} else {
''
}
g.enum_typedefs.writeln('} ${packed_attribute} ${enum_name};') g.enum_typedefs.writeln('} ${packed_attribute} ${enum_name};')
if node.typ != ast.int_type { if node.typ != ast.int_type {
g.enum_typedefs.writeln('#pragma pack(pop)\n') g.enum_typedefs.writeln('#pragma pack(pop)\n')

View File

@ -507,7 +507,7 @@ fn (mut g Gen) struct_decl(s ast.Struct, name string, is_anon bool) {
} }
// g.type_definitions.writeln('} $name;\n') // g.type_definitions.writeln('} $name;\n')
// //
ti_attrs := if s.attrs.contains('packed') { ti_attrs := if !g.is_cc_msvc && s.attrs.contains('packed') {
'__attribute__((__packed__))' '__attribute__((__packed__))'
} else { } else {
'' ''