# Type hierarchy within Clang.jl

**URL:** <https://discourse.julialang.org/t/type-hierarchy-within-clang-jl/85451>\
**Category:** New to Julia\
**Tags:** type, clang\
**Created:** [August 7, 2022, 11:02pm UTC](https://discourse.julialang.org/t/type-hierarchy-within-clang-jl/85451 "2022-08-07T23:02:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [August 7, 2022, 11:02pm UTC](https://discourse.julialang.org/t/type-hierarchy-within-clang-jl/85451/1 "2022-08-07T23:02:42Z")

</div>

I’m using Clang.jl to automatically generate julia wrappers over C structs, lets call them `MyType1`, `MyType2`, etc:

```julia
struct MyType1
    # generated by Clang.jl
end
struct MyType2
    # generated by Clang.jl
end

```

However, these are (as all concretes types by default) direct subtypes of `Any`. Instead I would like the generated types to be

```julia
abstract type AbstractMyType end
abstract type AbstractMyType1 <: AbstractMyType end
abstract type AbstractMyType2 <: AbstractMyType end
(...)
struct MyType1 <: AbstractMyType1
    # generated by Clang.jl
end
struct MyType2 <: AbstractMyType2
    # generated by Clang.jl
end

```

Is this possible?

---

<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:** [August 8, 2022, 12:33pm UTC](https://discourse.julialang.org/t/type-hierarchy-within-clang-jl/85451/2 "2022-08-08T12:33:03Z")

</div>

It’s possible as long as you know how to manipulate Julia AST.

> <https://github.com/JuliaInterop/Clang.jl/blob/39e3a25a6e932b48a5fa508e680de53296403627/docs/src/generator.md#rewrite-expressions-before-printing>
