Zig Version
0.11.0-dev.3+0bbb00035
Steps to Reproduce and Observed Behavior
The documentation for the 'align' keyword (section 13.2 of the Zig Language Reference) only covers the syntax for setting byte alignment.
However, section 15.3 'packed struct' shows that another syntax is valid, with an error message giving a hint on its meaning.
This example program also uses this syntax for align:
const std = @import("std");
const S = packed struct {
a: u2,
b: u2,
c: u2,
};
pub fn main() void {
var s: S = S{ .a = 1, .b = 2, .c = 3 };
const ptr: *align(1:2:1) u2 = &s.b;
std.debug.print("ptr = {}\n", .{ptr});
std.debug.print("@typeInfo(ptr) = {}\n", .{@typeInfo(@TypeOf(ptr))});
}
I don't see any indication that this syntax is valid, or how to use it, in the current documentation.
This came up with my project zig_tcl when dealing with bit aligned fields across a C API boundary, and I don't know how to proceed without a better understanding of alignment in Zig.
Expected Behavior
I expect documentation for the 'align' keyword to include this, seemingly valid, use of the keyword.
Zig Version
0.11.0-dev.3+0bbb00035
Steps to Reproduce and Observed Behavior
The documentation for the 'align' keyword (section 13.2 of the Zig Language Reference) only covers the syntax for setting byte alignment.
However, section 15.3 'packed struct' shows that another syntax is valid, with an error message giving a hint on its meaning.
This example program also uses this syntax for align:
I don't see any indication that this syntax is valid, or how to use it, in the current documentation.
This came up with my project zig_tcl when dealing with bit aligned fields across a C API boundary, and I don't know how to proceed without a better understanding of alignment in Zig.
Expected Behavior
I expect documentation for the 'align' keyword to include this, seemingly valid, use of the keyword.