2018-10-26 11:59:58 -07:00
|
|
|
const std = @import("std");
|
|
|
|
const assert = std.debug.assert;
|
2017-06-15 20:47:05 -07:00
|
|
|
const builtin = @import("builtin");
|
2018-10-26 11:59:58 -07:00
|
|
|
const maxInt = std.math.maxInt;
|
2017-06-15 20:47:05 -07:00
|
|
|
|
2018-11-13 05:08:37 -08:00
|
|
|
const Foo = struct {
|
2018-04-30 17:35:54 -07:00
|
|
|
x: u32,
|
|
|
|
y: u32,
|
|
|
|
z: u32,
|
|
|
|
};
|
2017-06-15 20:47:05 -07:00
|
|
|
|
2017-08-29 04:30:22 -07:00
|
|
|
test "@alignOf(T) before referencing T" {
|
2018-10-26 11:59:58 -07:00
|
|
|
comptime assert(@alignOf(Foo) != maxInt(usize));
|
2017-06-15 20:47:05 -07:00
|
|
|
if (builtin.arch == builtin.Arch.x86_64) {
|
2017-08-29 04:30:22 -07:00
|
|
|
comptime assert(@alignOf(Foo) == 4);
|
2017-06-15 20:47:05 -07:00
|
|
|
}
|
|
|
|
}
|