-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
v: implement aligned attr for struct #19915
Conversation
It needs a few lines to describe the attribute after https://github.com/vlang/v/blob/master/doc/docs.md#packed too. |
Also a pair of .vv and .c.must_have files in vlib/v/gen/c/testdata/ , to prevent potential future silent regressions. |
In your example, you show using In other words... there needs to be more documentation for this feature. If you're going to allow the attr without a number, the default needs to be documented. Possible values for the number after the |
Something else to document... does this force the alignment of the whole struct, or the fields within the struct? |
About the alignment factor (the parameter value), the GCC docs says about:
|
It is about the final struct sizing. |
497f7a8
to
3d3b897
Compare
And on that note: Have you verified that it works exactly the same in clang, msvc, zig, etc.? Yes, zig, as there is a way to use zig as the backend compiler for V. |
Yes. This pr changes works in gcc, clang, msvc. |
Fix #19775
It also works for MSVC.
🤖[deprecated] Generated by Copilot at a9b32f2
Add support for the
aligned
attribute for structs in C code generation. This allows specifying the memory alignment of structs and their fields for different compilers.🤖[deprecated] Generated by Copilot at a9b32f2
aligned
attribute for structs (link,