# What's the equivalent of C struct{...} \_\_attribute\_\_((packed))?

**URL:** <https://ziggit.dev/t/whats-the-equivalent-of-c-struct-attribute-packed/9364>\
**Category:** Help\
**Tags:** language\
**Created:** [March 31, 2025, 5:56am UTC](https://ziggit.dev/t/whats-the-equivalent-of-c-struct-attribute-packed/9364 "2025-03-31T05:56:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![yataro](https://ziggit.dev/letter_avatar_proxy/v4/letter/y/6de8d8/32.png) [@yataro](https://ziggit.dev/u/yataro)\
**Post date:** [March 31, 2025, 6:08am UTC](https://ziggit.dev/t/whats-the-equivalent-of-c-struct-attribute-packed/9364/2 "2025-03-31T06:08:42Z")

</div>

Packed Zig struct is a concept that differs from ` __attribute__ ((packed))`. I think there’s no direct equivalent, but you can achieve same result like this:

```c
struct __attribute__ ((packed)) foo
{
  char a;
  int c;
  char b;
};

```

becomes

```zig
const foo = extern struct {
    a: u8 align(1),
    c: c_int align(1),
    b: u8 align(1),
};

```

With alignment of `1` there would be no padding bytes between fields. You can also utilize `translate-c` feature to construct struct definitions like this from their C counterpart.

Side question, why would you want this?

Welcome to Ziggit btw 😁

---

_[View the full topic](https://ziggit.dev/t/whats-the-equivalent-of-c-struct-attribute-packed/9364)._
