Skip to content

Commit

Permalink
cgen: fix msvc packed attr (#18437)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jun 14, 2023
1 parent 530f73b commit 23da212
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion vlib/v/gen/c/cgen.v
Expand Up @@ -3798,7 +3798,11 @@ fn (mut g Gen) enum_decl(node ast.EnumDecl) {
g.enum_typedefs.writeln(', // ${cur_value}')
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};')
if node.typ != ast.int_type {
g.enum_typedefs.writeln('#pragma pack(pop)\n')
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/gen/c/struct.v
Expand Up @@ -507,7 +507,7 @@ fn (mut g Gen) struct_decl(s ast.Struct, name string, is_anon bool) {
}
// 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__))'
} else {
''
Expand Down

0 comments on commit 23da212

Please sign in to comment.