Memory layout in Zig with formulas

(raymondtana.github.io)

37 points | by raymondtana 5 hours ago ago

5 comments

  • raymondtana 5 hours ago

    I've been learning Zig, and needed a refresher on memory layout (@sizeOf and @alignOf).

    Wrote this blog post to summarize what I think are the right ways to understand alignment and size for various data types in Zig, just through experimentation.

    Let me know any and all feedback!

    • dnautics an hour ago

      i could be wrong but i believe the zig compiler reserves the right to lay things out differently depending on compilation mode? especially debug. unless it's extern or packed, in which case the layout will be defined.

  • bk496 37 minutes ago

    useful!