You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BTW, packed struct in Rust also can specify alignment, but packed struct in Zig only can specify backed integer
#![allow(unused)]fn main(){// Default representation, alignment lowered to 2.#[repr(packed(2))]structPackedStruct{first:i16,second:i8,third:i32}// C representation, alignment raised to 8#[repr(C, align(8))]structAlignedStruct{first:i16,second:i8,third:i32}
The text was updated successfully, but these errors were encountered:
CGQAQ
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Nov 8, 2022
packed structs in Zig do not align to packed structs in C. what you're likely looking for is extern struct setting align(1) on the fields. related: #13009 and #12852
extern struct is for guaranteeing layout, whereas packed struct is for making a struct that has a backing integer representation, similar to the way enums work
andrewrk
added
question
No questions on the issue tracker, please.
and removed
bug
Observed behavior contradicts documented or intended behavior
labels
Nov 8, 2022
Reproduce repo
https://github.com/CGQAQ/zig-pnginfo/tree/reproduce
Zig Version
0.11.0-dev.86+b83e4d965
Steps to Reproduce and Observed Behavior
Expected Behavior
chunk.chunk_type should not be modified
Normal struct with alignment 1 run correctly
https://github.com/CGQAQ/zig-pnginfo/tree/main
in contrast, c works fine
BTW, packed struct in Rust also can specify alignment, but packed struct in Zig only can specify backed integer
The text was updated successfully, but these errors were encountered: