mirror of
https://github.com/ziglang/zig.git
synced 2025-12-10 00:03:10 +00:00
byteOffsetOf add fields to non-packet struct to maintain symmetry
This commit is contained in:
parent
0456b2145d
commit
2545f44db0
@ -18,6 +18,8 @@ const A = struct {
|
||||
e: u5,
|
||||
f: u16,
|
||||
g: u16,
|
||||
h: u9,
|
||||
i: u7,
|
||||
};
|
||||
|
||||
const P = packed struct {
|
||||
@ -53,6 +55,8 @@ test "@byteOffsetOf" {
|
||||
expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @byteOffsetOf(A, "e"));
|
||||
expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @byteOffsetOf(A, "f"));
|
||||
expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @byteOffsetOf(A, "g"));
|
||||
expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @byteOffsetOf(A, "h"));
|
||||
expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @byteOffsetOf(A, "i"));
|
||||
}
|
||||
|
||||
test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user