Skip to content

Commit

Permalink
implement attr
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 17, 2023
1 parent b347f54 commit a9b32f2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vlib/v/gen/c/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,19 @@ fn (mut g Gen) struct_decl(s ast.Struct, name string, is_anon bool) {
} else {
g.type_definitions.writeln('\tEMPTY_STRUCT_DECLARATION;')
}
ti_attrs := if !g.is_cc_msvc && s.attrs.contains('packed') {
mut ti_attrs := if !g.is_cc_msvc && s.attrs.contains('packed') {
'__attribute__((__packed__))'
} else {
''
}
if attr := s.attrs.find_first('aligned') {
attr_arg := if attr.arg == '' { '' } else { ' (${attr.arg})' }
ti_attrs += if g.is_cc_msvc {
'__declspec(align(${attr_arg}))'
} else {
' __attribute__((aligned${attr_arg}))'
}
}
g.type_definitions.write_string('}${ti_attrs}')
if !is_anon {
g.type_definitions.write_string(';')
Expand Down

0 comments on commit a9b32f2

Please sign in to comment.