mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
22 lines
300 B
Zig
22 lines
300 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
const BitField = packed struct {
|
|
a: u3,
|
|
b: u3,
|
|
c: u2,
|
|
};
|
|
|
|
var foo = BitField{
|
|
.a = 1,
|
|
.b = 2,
|
|
.c = 3,
|
|
};
|
|
|
|
test "pointer to non-byte-aligned field" {
|
|
const ptr = &foo.b;
|
|
try expect(ptr.* == 2);
|
|
}
|
|
|
|
// test
|