mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
parent
844e05f619
commit
6f250f568a
@ -9,8 +9,7 @@ test "enum type" {
|
||||
assert(bar == Bar.B);
|
||||
assert(@memberCount(Foo) == 3);
|
||||
assert(@memberCount(Bar) == 4);
|
||||
const expected_foo_size = 16 + @sizeOf(usize);
|
||||
assert(@sizeOf(Foo) == expected_foo_size);
|
||||
assert(@sizeOf(Foo) == @sizeOf(FooNoVoid));
|
||||
assert(@sizeOf(Bar) == 1);
|
||||
}
|
||||
|
||||
@ -30,6 +29,10 @@ const Foo = enum {
|
||||
Two: Point,
|
||||
Three: void,
|
||||
};
|
||||
const FooNoVoid = enum {
|
||||
One: i32,
|
||||
Two: Point,
|
||||
};
|
||||
const Bar = enum {
|
||||
A,
|
||||
B,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
const assert = @import("std").debug.assert;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const StructWithNoFields = struct {
|
||||
fn add(a: i32, b: i32) -> i32 { a + b }
|
||||
@ -257,7 +258,12 @@ test "packed struct 24bits" {
|
||||
assert(@sizeOf(Foo96Bits) == 12);
|
||||
}
|
||||
|
||||
var value = Foo96Bits {
|
||||
// TODO workaround for LLVM bug on windows
|
||||
// http://lists.llvm.org/pipermail/llvm-dev/2017-September/117864.html
|
||||
const align_bytes = if (builtin.os == builtin.Os.windows and
|
||||
builtin.arch == builtin.Arch.x86_64) 32 else @alignOf(Foo96Bits);
|
||||
|
||||
var value align(align_bytes) = Foo96Bits {
|
||||
.a = 0,
|
||||
.b = 0,
|
||||
.c = 0,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user