Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/translate_c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,8 @@ fn transRecordDecl(c: *Context, scope: *Scope, record_decl: *const clang.RecordD
else => |e| return e,
};

const alignment = if (flexible_field != null and field_decl.getFieldIndex() == 0)
@as(c_uint, @intCast(record_alignment))
const alignment: ?c_uint = if (flexible_field == null and field_decl.getFieldIndex() == 0)
@intCast(record_alignment)
else
ClangAlignment.forField(c, field_decl, record_def).zigAlignment();

Expand Down
12 changes: 12 additions & 0 deletions test/cases/translate_c/aligned_struct.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
struct __attribute__((aligned(16))) foo {
int bar;
int baz;
};

// translate-c
// c_frontend=aro,clang
//
// pub const struct_foo = extern struct {
// bar: c_int align(16) = @import("std").mem.zeroes(c_int),
// baz: c_int = @import("std").mem.zeroes(c_int),
// };
Loading