# Packed struct

**URL:** <https://discourse.julialang.org/t/packed-struct/33394>\
**Category:** Performance\
**Created:** [January 15, 2020, 1:01pm UTC](https://discourse.julialang.org/t/packed-struct/33394 "2020-01-15T13:01:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![garychow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garychow/32/11734_2.png) [@garychow](https://discourse.julialang.org/u/garychow)\
**Post date:** [January 15, 2020, 1:01pm UTC](https://discourse.julialang.org/t/packed-struct/33394/1 "2020-01-15T13:01:14Z")

</div>

Hi,

I have some binary data which I would like to unpack to some struct. However, as far as I know julia does not support the packed (ie non aligned without padding) struct and that make it impossible to use unsafe\_wrap to decode those data without copying the data. I tried many options and looks like the closest thing is the cbinding packege, which allow packed c struct but still wont allow direct dereferencing without copying.

May I ask if anyone has the same problem and how difficult to allow julia normal composite to support this packed struct?

thanks

---

<div class="post-metadata">

**Author:** ![Gnimuc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnimuc/32/2194_2.png) [@Gnimuc](https://discourse.julialang.org/u/Gnimuc)\
**Post date:** [January 16, 2020, 11:08am UTC](https://discourse.julialang.org/t/packed-struct/33394/2 "2020-01-16T11:08:55Z")

</div>

you may also be interested in this package:

> **[GitHub - JuliaIO/StructIO.jl: Experimental new implementation of...](https://github.com/JuliaIO/StructIO.jl)**
>
> Experimental new implementation of StrPack.jl-like functionality - GitHub - JuliaIO/StructIO.jl: Experimental new implementation of StrPack.jl-like functionality

---

<div class="post-metadata">

**Author:** ![garychow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garychow/32/11734_2.png) [@garychow](https://discourse.julialang.org/u/garychow)\
**Post date:** [January 16, 2020, 11:16am UTC](https://discourse.julialang.org/t/packed-struct/33394/3 "2020-01-16T11:16:29Z")

</div>

Thanks,

Tried that and the dereferencing does not work.

I guess it has to be solved fundamentally so that the generic struct support the packed structure
