# Translating a C type with Julia embedded to a Julia type of the same layout

**URL:** <https://discourse.julialang.org/t/translating-a-c-type-with-julia-embedded-to-a-julia-type-of-the-same-layout/20065>\
**Category:** General Usage\
**Tags:** embedding\
**Created:** [January 24, 2019, 11:34pm UTC](https://discourse.julialang.org/t/translating-a-c-type-with-julia-embedded-to-a-julia-type-of-the-same-layout/20065 "2019-01-24T23:34:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 24, 2019, 11:34pm UTC](https://discourse.julialang.org/t/translating-a-c-type-with-julia-embedded-to-a-julia-type-of-the-same-layout/20065/1 "2019-01-24T23:34:50Z")

</div>

Hi,

I am trying to figure out the Julia equivalents of the types in this Julia embedded struct [https://github.com/JuliaLang/julia/blob/master/src/julia.h#L1615](https://github.com/JuliaLang/julia/blob/master/src/julia.h#L1615). Is there any mapping list (couldn’t find in the docs) of what the `jl_` types (and the other ones) map to in Julia? I want to translate this whole type to Julia, such that the Julia and C types will have the same memory layout. Any tips?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [January 24, 2019, 11:57pm UTC](https://discourse.julialang.org/t/translating-a-c-type-with-julia-embedded-to-a-julia-type-of-the-same-layout/20065/2 "2019-01-24T23:57:50Z")

</div>

`jl_task_t` is mapped to the `Task` type in julia and you should just use that if possible. (However for `Task` there are several hidden fields after the ones which are exposed to julia, marked in the source with the “hidden fields” comment. These are generally the parts which are not required on the julia side and have no neat / safe representation there. Like the task’s stack, for instance.)

Generally to know about how types in the C runtime are reflected into julia, you can grep for `jl_new_datatype`. Nearly all the uses of this are in `src/jltypes.c` (other than `Task`, which is in task.c).

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 25, 2019, 12:17am UTC](https://discourse.julialang.org/t/translating-a-c-type-with-julia-embedded-to-a-julia-type-of-the-same-layout/20065/3 "2019-01-25T00:17:26Z")

</div>

Thanks for the tips and info. The hidden fields seem hard to crack though.

---

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [January 25, 2019, 12:27am UTC](https://discourse.julialang.org/t/translating-a-c-type-with-julia-embedded-to-a-julia-type-of-the-same-layout/20065/4 "2019-01-25T00:27:33Z")

</div>

> [@mohamed82008](#):
>
> The hidden fields seem hard to crack though.

I’m not sure exactly what you mean by that 🙂 Do you need to look at the hidden fields and if so, why?

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 25, 2019, 12:34am UTC](https://discourse.julialang.org/t/translating-a-c-type-with-julia-embedded-to-a-julia-type-of-the-same-layout/20065/5 "2019-01-25T00:34:30Z")

</div>

I will reconsider what I need to do.
