# Wrapping simple structures with CxxWrap

**URL:** https://discourse.julialang.org/t/wrapping-simple-structures-with-cxxwrap/36945
**Category:** General Usage
**Tags:** cxx
**Created:** [April 3, 2020, 9:59am UTC](https://discourse.julialang.org/t/wrapping-simple-structures-with-cxxwrap/36945 "2020-04-03T09:59:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![xor0110](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xor0110/32/7926_2.png) [@xor0110](https://discourse.julialang.org/u/xor0110)
#### Post date: [April 3, 2020, 9:59am UTC](https://discourse.julialang.org/t/wrapping-simple-structures-with-cxxwrap/36945/1 "2020-04-03T09:59:27Z")

</div>

I’m trying to use CxxWrap, and my C++ library contains a simple structure like this:

```julia
struct Address
{
    uint8_t a;
    uint8_t b;
    uint8_t c;
    uint8_t d;
};

```

Right now I’m getting this problem when I try to compile my bindings:

```julia
C++ exception while wrapping module CppHello: No appropriate factory for type 7Address
ERROR: LoadError: No appropriate factory for type 7Address

```

If I try to add this to the C++ code  
`mod.add_type<Address>("struct Address");`  
I get this:

```julia
 error: static assertion failed: Mirrored types (marked with IsMirroredType) can't be added using add_type, map them directly to a struct instead and use map_type or explicitly disable mirroring for this type, e.g. define template<> struct IsMirroredType<Foo> : std::false_type { };
   static_assert(!IsMirroredType<T>::value, "Mirrored types (marked with IsMirroredType) can't be added using add_type, map them directly to a struct instead and use map_type or explicitly disable mirroring for this type, e.g. define template<> struct IsMirroredType<Foo> : std::false_type { };");

```

which is actually an error that is mentioned in the CxxWrap readme. I don’t quite understand, though, what are my alternatives? How do I “wrap them normally” to quote the readme, and how exactly do I use the `IsMirroredType`?

---

<div class="post-metadata">

### Author: ![Ilay101](https://avatars.discourse-cdn.com/v4/letter/i/bb73d2/32.png) [@Ilay101](https://discourse.julialang.org/u/Ilay101)
#### Post date: [April 9, 2020, 6:38pm UTC](https://discourse.julialang.org/t/wrapping-simple-structures-with-cxxwrap/36945/2 "2020-04-09T18:38:24Z")

</div>

I ran in the same issue and eventually got it working.  
If you want to use map\_type, you need to create an equivalent julia structure on the julia side.

```julia
mutable struct Address
  a::UInt8
  b::UInt8
  c::UInt8
  d::UInt8
end

```

This type must be declared before using the `@wrapmodule` macro
