mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 15:43:06 +00:00
* remove `@setGlobalAlign` * add align keyword for setting alignment on functions and variables. * loads and stores use alignment from pointer * memcpy, memset use alignment from pointer * add syntax for pointer alignment * slices can have volatile * add u2, i2 primitives * ignore preferred align and use abi align everywhere * back to only having alignOf builtin. preferredAlignOf is too tricky to be useful. See #432. Partial revert of e726925e802eddab53cbfd9aacbc5eefe95c356f. See #37
12 lines
328 B
Zig
12 lines
328 B
Zig
const assert = @import("std").debug.assert;
|
|
const builtin = @import("builtin");
|
|
|
|
const Foo = struct { x: u32, y: u32, z: u32, };
|
|
|
|
test "@alignOf(T) before referencing T" {
|
|
comptime assert(@alignOf(Foo) != @maxValue(usize));
|
|
if (builtin.arch == builtin.Arch.x86_64) {
|
|
comptime assert(@alignOf(Foo) == 4);
|
|
}
|
|
}
|