Hacker News new | past | comments | ask | show | jobs | submit login

regular structs in Zig have an implementation-defined layout in memory - the compiler is allowed to re-order fields, add padding, etc.

if you want control over the memory layout you need either a packed struct or an extern struct [0].

0: https://ziglang.org/documentation/0.9.1/#extern-struct




With respect, Iā€™m not sure that answered the question. Surely in a sudoku game the default layout of structs would be absolutely fine, no?


ahh, I might have misunderstood the question - I wasn't sure if they were asking about Zig in general or my solver in particular.

yes, normal structs would have worked fine - like I said, I was learning Zig in the process, so I was going out of my way to experiment with its unique features.


Yes, I meant in your sudoku solver, sorry, I should've been more clear.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: