# Struct in julia to C structs

**URL:** <https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817>\
**Category:** General Usage\
**Tags:** embedding\
**Created:** [November 1, 2017, 2:53am UTC](https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817 "2017-11-01T02:53:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sysint64](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sysint64/32/2398_2.png) [@sysint64](https://discourse.julialang.org/u/sysint64)\
**Post date:** [November 1, 2017, 2:53am UTC](https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817/1 "2017-11-01T02:53:19Z")

</div>

Hello, julia structs is the same as C structs or not? i.e.:

```nohighlight
struct Test
    x::Int
    y::Int 
end

```

will this be the same as this?

```nohighlight
struct {
    int x;
    inx y;
}

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [November 1, 2017, 3:07am UTC](https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817/2 "2017-11-01T03:07:20Z")

</div>

No, use `Cint` instead.

---

<div class="post-metadata">

**Author:** ![sysint64](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sysint64/32/2398_2.png) [@sysint64](https://discourse.julialang.org/u/sysint64)\
**Post date:** [November 1, 2017, 3:11am UTC](https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817/3 "2017-11-01T03:11:53Z")

</div>

i.e.:

```nohighlight
struct Test
    x::Cint
    y::Cint
end

```

for me the main thing is that no additional fields are added to the struct after compilation.

---

<div class="post-metadata">

**Author:** ![sysint64](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sysint64/32/2398_2.png) [@sysint64](https://discourse.julialang.org/u/sysint64)\
**Post date:** [November 1, 2017, 3:45am UTC](https://discourse.julialang.org/t/struct-in-julia-to-c-structs/6817/4 "2017-11-01T03:45:17Z")

</div>

Yeah, they have the same data layout, read it in the [documentation](https://docs.julialang.org/en/latest/manual/calling-c-and-fortran-code/#Struct-Type-correspondences-1)
