Real Time Industrial Ethernet Protocol (EtherCAT) Library Design

For your layout/serialization concerns, I think your best friend here is the language reference. You’ll find information about the layout of structs, endian-ness of packed structs, etc: Documentation - The Zig Programming Language

For endian-ness of packed structs, it’s always lowest-to-highest:

Fields remain in the order declared, least to most significant.

Normal structs do not have defined layouts. You may have to use extern here to get what you want: Documentation - The Zig Programming Language

If well-defined in-memory layout is not required, struct is a better choice because it places fewer restrictions on the compiler.

3 Likes