-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Array alignment #2673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The syntax is
Or
The alignment is a property of the variable (memory location), not the type. |
e.g. I have a function: pub const State = [48]u8;
pub fn foo(state: *align(4)State) void { And I want a user to be able to write: fn bar() {
var state: State = StateInitializer;
foo(&state);
} Then they get an alignment error. How can they fix it? |
They would have to put the alignment on the var state: State align(4) = StateInitializer; If you want to encapsulate this into a type you'll need to use a struct and this issue needs to be implemented: #1512 |
Thanks. I'm working around it for now by lying about the type (saying it's a |
As part of my module's public members, I want to expose a type that is an array of
u8
withalign(4)
.This currently fails with
The text was updated successfully, but these errors were encountered: