From 77d8336db97145aa331ae8b1bdb07f8427ca4262 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 5 Apr 2021 06:49:43 +0300 Subject: [PATCH] cgen: [packed] struct attribute --- vlib/v/gen/c/cgen.v | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 8762a7442d..b1cc26ce35 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -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 {