# Reinterpret\_cast

**URL:** <https://discourse.julialang.org/t/reinterpret-cast/69169>\
**Category:** New to Julia\
**Created:** [October 4, 2021, 8:36am UTC](https://discourse.julialang.org/t/reinterpret-cast/69169 "2021-10-04T08:36:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![whatsthecraic](https://avatars.discourse-cdn.com/v4/letter/w/7bcc69/32.png) [@whatsthecraic](https://discourse.julialang.org/u/whatsthecraic)\
**Post date:** [October 4, 2021, 8:36am UTC](https://discourse.julialang.org/t/reinterpret-cast/69169/1 "2021-10-04T08:36:37Z")

</div>

suppose I have a function such as `function foo(::A);`, I’d like to check how it is compiled with `@code_llvm foo(a)`, but I don’t know or care how to create an instance of the class A. Is there a way to achieve that without having to create an instance of A, for instance with a bogus expression as in C++ by `reinterpret_cast<A*>(nullptr);`

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [October 4, 2021, 8:41am UTC](https://discourse.julialang.org/t/reinterpret-cast/69169/2 "2021-10-04T08:41:15Z")

</div>

Use the non-macro version:

```julia
julia> struct A end; foo(x) = x
foo (generic function with 1 method)

julia> code_llvm(foo, (A,))
; @ REPL[3]:1 within `foo'
define void @julia_foo_184() {
top:
  ret void
}

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [October 4, 2021, 8:41am UTC](https://discourse.julialang.org/t/reinterpret-cast/69169/3 "2021-10-04T08:41:17Z")

</div>

The macro [`@code_llvm`](https://docs.julialang.org/en/v1/stdlib/InteractiveUtils/#InteractiveUtils.@code_llvm) is actually just a user-friendly interface to the function [`code_llvm`](https://docs.julialang.org/en/v1/stdlib/InteractiveUtils/#InteractiveUtils.code_llvm). This function takes the function and the types as input:

```julia
julia> struct A end;

julia> foo(::A) = 1 + 1;

julia> code_llvm(foo, (A,))
; @ REPL[5]:1 within `foo'
define i64 @julia_foo_179() {
top:
  ret i64 2
}

```
